Re: Run analyze on schema

From: Jerry Sievers <gsievers19(at)comcast(dot)net>
To: Suresh Raja <suresh(dot)rajaabc(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: Run analyze on schema
Date: 2015-06-22 23:53:59
Message-ID: 86ioaf1eqw.fsf@jerry.enova.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Suresh Raja <suresh(dot)rajaabc(at)gmail(dot)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(dot)consulting(at)comcast(dot)net
p: 312.241.7800

In response to

Responses

Browse pgsql-general by date

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

Browse pgsql-sql by date

  From Date Subject
Next Message Suresh Raja 2015-06-24 03:34:05 Re: [GENERAL] Run analyze on schema
Previous Message Suresh Raja 2015-06-22 21:10:23 Run analyze on schema