Skip to main content

I would like to detect from a postgis database the number of records and the filesizes (mb) of the tables in a schema so i can write it to xlsx.

 

I can't find the solution.

You can get the number of records with a count() in an SQLExecutor, e.g.

select count(*) as record_count from my_table

Expose the attribute "record_count" which will then contain the number of records in my_table.

Concerning the file sizes, which file sizes are you referring to? External files referenced in the table, or the table contents itself?


The table contents itself. I have tried your solution with select count(*) but it gives an error that my_table not excists. If i specify de schema and table then it works OK.

 

Is there maybe a wildcard, that makes it possible to count the records of all of my tables?

The table contents itself. I have tried your solution with select count(*) but it gives an error that my_table not excists. If i specify de schema and table then it works OK.

 

Is there maybe a wildcard, that makes it possible to count the records of all of my tables?

Exactly, if you query a table that isn't in the login user's default schema, you will have to specify the schema.


In an SQLExecutor, try the query listed under "General Table Size Information" here:

https://wiki.postgresql.org/wiki/Disk_Usage

It will give you a lot of information about all the database tables, including estimated record counts and table file sizes.


If you require accurate record counts, you can try the query suggested here (it may be noticably slower than the estimated record count):

https://stackoverflow.com/a/38684225/10661889

 


Thank you very much.


Reply