Re: Run analyze on schema - Mailing list pgsql-general

From Jerry Sievers
Subject Re: Run analyze on schema
Date
Msg-id 86ioaf1eqw.fsf@jerry.enova.com
Whole thread Raw
In response to Run analyze on schema  (Suresh Raja <suresh.rajaabc@gmail.com>)
Responses Re: Run analyze on schema  (Suresh Raja <suresh.rajaabc@gmail.com>)
List pgsql-general
Suresh Raja <suresh.rajaabc@gmail.com> writes:

>     Hi All:
>
>     Does postgresql support schema analyze.  I could not find
>     analyze schema anywhere.  Can we create a function to run
>     analyze and reindex on all objects in the schema.  Any
>     suggestions or ideas.

Yes "we" certainly can...

begin;

create function foo(sch text)
returns void as

$$
declare sql text;

begin

for sql in
select format('analyze verbose %s.%s', schemaname, tablename) from pg_tables
where schemaname = sch

loop execute sql; end loop;

end
$$ language plpgsql;

select foo('public');
select foo('pg_catalog');


-- Enjoy!!

>
>     Thanks,
>     -Suresh Raja
>

--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@comcast.net
p: 312.241.7800


pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: How to speed up pg_trgm / gin index scan
Next
From: Tom Lane
Date:
Subject: Re: Re: pg_dump 8.4.9 failing after upgrade to openssl-1.0.1e-30.el6_6.11.x86_64 on redhat linux