Skip to main content
Question

get numberrecords and filesize

  • March 5, 2019
  • 6 replies
  • 71 views

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.
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

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

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.