How to analyze all tables in one schema (edited)

Moderator: NorbertKrupa

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

How to analyze all tables in one schema (edited)

Post by Julie » Wed Jan 23, 2013 4:30 pm

Hello,

Is there a way I can analyze all the tables in a schema with one command? This one doesn't work:

Code: Select all

dbadmin=> select analyze_statistics('mydata_wh');
ERROR 2065:  analyze_statistics: Invalid table/projection/column mydata_wh
Last edited by Julie on Thu Jan 24, 2013 1:13 pm, edited 2 times in total.
Thanks,
Juliette

jpcavanaugh
Intermediate
Intermediate
Posts: 149
Joined: Mon Apr 30, 2012 10:04 pm
Location: New York
Contact:

Re: How to analyze all schema tables

Post by jpcavanaugh » Wed Jan 23, 2013 5:33 pm

Just give it an empty string as the argument.

Code: Select all

select analyze_statistics('');

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

Re: How to analyze all schema tables

Post by Julie » Wed Jan 23, 2013 5:50 pm

Thanks! But does passing in no argments analyze the tables in all schemas of the active database? We have 10 schemas, but I just want to analyze the 100 or so tables in one of those schemas.
Thanks,
Juliette

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

Re: How to analyze tables in one schema (edited)

Post by Julie » Thu Jan 24, 2013 1:13 pm

My original post title was misleading so it from "How to analyze all schema tables" to "How to analyze all tables in one schema (edited)".
Thanks,
Juliette

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

Re: How to analyze all tables in one schema (edited)

Post by JimKnicely » Thu Jan 24, 2013 3:19 pm

Hi Julie,

I do something like the following to generate a script file that contains all the analyze commands for the tables in a single schema and the run the script file:

Code: Select all

dbadmin=> \t
Tuples only is off.
dbadmin=> \t
Showing only tuples.
dbadmin=> \o /usr/home/dbadmin/analyze.sql
dbadmin=> select 'select analyze_statistics(''' || table_schema || '.' || table_name || ''');' from tables where table_schema = 'myschema';
dbadmin=> \o
dbadmin=> \i /usr/home/dbadmin/analyze.sql

                  0

                  0

                  0

                  0

                  0

                  0

                  0
 
etc...
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.

Post Reply

Return to “New to Vertica Database Administration”