Is there a SYSTEM table with row counts?

Moderator: NorbertKrupa

Post Reply
User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

Is there a SYSTEM table with row counts?

Post by Julie » Thu Oct 11, 2012 5:05 pm

Hi y'all,

Is there a SYSTEM table in Vertica that contains the current row counts for all tables in the database?
Thanks,
Juliette

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Is there a SYSTEM table with row counts?

Post by JimKnicely » Fri Oct 12, 2012 12:40 pm

Hi Juliette,

Of course the simplest way to get a table row count is via the COUNT aggregate function:

Code: Select all

dbadmin=> SELECT COUNT(*) FROM verticadb_wh.date_dim;
 COUNT
-------
  4752
(1 row)
Remember that in Vertica that tables do not actually contain data; its their associated projections that do! Therefore, another method is via the ROW_COUNT column of the PROJECTION_STORAGE system table:

Code: Select all

dbadmin=> SELECT MAX(row_count) row_count
dbadmin->   FROM projection_storage
dbadmin->  WHERE anchor_table_schema = 'verticadb_wh'
dbadmin->    AND anchor_table_name = 'date_dim';
 row_count
-----------
      4752
(1 row)
Hope this helps!
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

Re: Is there a SYSTEM table with row counts?

Post by Julie » Fri Oct 19, 2012 7:38 pm

Thank you! I'll create my own view having a column named row_count using your query to populate it!
Thanks,
Juliette

Post Reply

Return to “New to Vertica Database Administration”