Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z7BXk-0004fO-Ib for pgsql-general@arkaria.postgresql.org; Mon, 22 Jun 2015 23:54:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z7BXk-00080O-2o for pgsql-general@arkaria.postgresql.org; Mon, 22 Jun 2015 23:54:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z7BXh-0007zr-3u for pgsql-general@postgresql.org; Mon, 22 Jun 2015 23:54:21 +0000 Received: from resqmta-ch2-03v.sys.comcast.net ([2001:558:fe21:29:69:252:207:35]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z7BXc-0006kB-M5 for pgsql-general@postgresql.org; Mon, 22 Jun 2015 23:54:20 +0000 Received: from resomta-ch2-08v.sys.comcast.net ([69.252.207.104]) by resqmta-ch2-03v.sys.comcast.net with comcast id jbu51q0052Fh1PH01buBMs; Mon, 22 Jun 2015 23:54:11 +0000 Received: from jerry.enova.com ([38.98.177.132]) by resomta-ch2-08v.sys.comcast.net with comcast id jbtz1q00N2rmZlA01bu1sB; Mon, 22 Jun 2015 23:54:09 +0000 Received: by jerry.enova.com (Postfix, from userid 1001) id 5A1AD7401EC; Mon, 22 Jun 2015 18:53:59 -0500 (CDT) From: Jerry Sievers To: Suresh Raja Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: Run analyze on schema References: Date: Mon, 22 Jun 2015 18:53:59 -0500 In-Reply-To: (Suresh Raja's message of "Mon, 22 Jun 2015 16:10:23 -0500") Message-ID: <86ioaf1eqw.fsf@jerry.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1435017251; bh=JJ+QYKjBfKkYp94kdghP5NzwX6umrOF7mxWL23kczCQ=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=k3mbpHvWk0Rgas3woA9wsJmYq2jpaueCQcblXqgqjOa2mKR4Gtz7WlXGIogazTaif OZT28PYyzX2dv+vI1uhXgRyupt3P7EU6VHz/handdOhx2txeprPJPSJb4cDpd0at3W JWrtlQw0b5UUIlyx5pX+ls8vSlSWiQUxKonzJdJD7ZXEU1F/+4KV4l9+F22wDd8tDQ VyYdTRc+QJtpjeRE8vtDkwhQrHYSVxn0hz3vnojxU+I1y6FNcdvoV9LJrg8LK3wSAq 5R7ExATvdBTnwcoH2OQCjEcrJDnoxLaYT1T0ltUoJEJ5kJgP6x97HR5Sd2zy6L7v1K jHwTe5hlvF5EA== X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Suresh Raja 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