Skip to main content
Question

get numberrecords and filesize


Forum|alt.badge.img

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.

6 replies

david_r
Celebrity
  • March 5, 2019

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?


Forum|alt.badge.img
  • Author
  • March 5, 2019

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?

david_r
Celebrity
  • March 5, 2019
kees_v wrote:

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.


david_r
Celebrity
  • March 5, 2019

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.


david_r
Celebrity
  • March 5, 2019

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

 


Forum|alt.badge.img
  • Author
  • March 5, 2019

Thank you very much.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings