agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
Run analyze on schema
3+ messages / 2 participants
[nested] [flat]

* Run analyze on schema
@ 2015-06-22 21:10 Suresh Raja <suresh.rajaabc@gmail.com>
  2015-06-22 23:53 ` Re: Run analyze on schema Jerry Sievers <gsievers19@comcast.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Suresh Raja @ 2015-06-22 21:10 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

>
> 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.
>
> Thanks,
> -Suresh Raja
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Run analyze on schema
  2015-06-22 21:10 Run analyze on schema Suresh Raja <suresh.rajaabc@gmail.com>
@ 2015-06-22 23:53 ` Jerry Sievers <gsievers19@comcast.net>
  2015-06-24 03:34   ` Re: [GENERAL] Run analyze on schema Suresh Raja <suresh.rajaabc@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Jerry Sievers @ 2015-06-22 23:53 UTC (permalink / raw)
  To: Suresh Raja <suresh.rajaabc@gmail.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

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


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [GENERAL] Run analyze on schema
  2015-06-22 21:10 Run analyze on schema Suresh Raja <suresh.rajaabc@gmail.com>
  2015-06-22 23:53 ` Re: Run analyze on schema Jerry Sievers <gsievers19@comcast.net>
@ 2015-06-24 03:34   ` Suresh Raja <suresh.rajaabc@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Suresh Raja @ 2015-06-24 03:34 UTC (permalink / raw)
  To: Jerry Sievers <gsievers19@comcast.net>; +Cc: pgsql-general@postgresql.org; pgsql-sql

On Mon, Jun 22, 2015 at 6:53 PM, Jerry Sievers <gsievers19@comcast.net>
wrote:

> 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
>


Thanks Jerry!

I too your example and added exception handling into it.

Thanks

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2015-06-24 03:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-06-22 21:10 Run analyze on schema Suresh Raja <suresh.rajaabc@gmail.com>
2015-06-22 23:53 ` Jerry Sievers <gsievers19@comcast.net>
2015-06-24 03:34   ` Suresh Raja <suresh.rajaabc@gmail.com>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox