How to refresh table statistics in Redshift?

926 Views Asked by At

I need to run a procedure over Redshift, that would check the number of rows inserted in a table each day. For that, I am using the svv_table_info which contains a column tbl_rows. This column contains information on the total number of records in a table. For my procedure, I would simply keep a check on the difference of the number of records in the table on that day to the previous day, using the tbl_rows. But, for some table statistics aren't properly refreshed as the stats_off column isn't exactly zero in the above svv table.
Now, I have a table info_schema_table which contains the information of the tables that I want to check on a daily basis. What I want to do in my procedure is that for every table in my info_schema_table, I want to refresh statistics at the beginning of the procedure. I tried using the analyze table_name command in Redshift, but it doesn't update the tbl_rows column to the latest value. I am new to Redshift and don't know how to refresh the statistics. Please help me out.
The complete details of my procedure is given in this post: Remove loop in Redshift
Also, the tables in info_schema_table are for insertion only, so their size is only increasing day by day.

0

There are 0 best solutions below