Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2749A1337BD7 for ; Tue, 19 Apr 2011 12:36:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 80304-01-7 for ; Tue, 19 Apr 2011 15:35:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [76.96.30.16]) by mail.postgresql.org (Postfix) with ESMTP id 2D5AD1337C46 for ; Tue, 19 Apr 2011 12:20:02 -0300 (ADT) Received: from omta04.emeryville.ca.mail.comcast.net ([76.96.30.35]) by qmta01.emeryville.ca.mail.comcast.net with comcast id ZSD71g0020lTkoCA1TL1Ek; Tue, 19 Apr 2011 15:20:01 +0000 Received: from homie ([69.59.255.15]) by omta04.emeryville.ca.mail.comcast.net with comcast id ZTKb1g00V0LiXQt8QTKhzk; Tue, 19 Apr 2011 15:19:56 +0000 Received: by homie (Postfix, from userid 1000) id 57ABE20C6F; Tue, 19 Apr 2011 11:19:33 -0400 (EDT) From: Jerry Sievers To: jweatherman91@alumni.wfu.edu Cc: pgsql-admin@postgresql.org Subject: Re: PKs without indexes References: <1303209946.7538.12.camel@darkflame.weatherman.net> Date: Tue, 19 Apr 2011 11:19:33 -0400 In-Reply-To: <1303209946.7538.12.camel@darkflame.weatherman.net> (John P. Weatherman's message of "Tue, 19 Apr 2011 05:45:46 -0500") Message-ID: <8762qap8u2.fsf@comcast.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.345 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201104/176 X-Sequence-Number: 37357 John P Weatherman writes: > Hi all, > > I am attempting to set up slony-i and have run into a minor > glitch...apparently whoever designed the database I have inherited > didn't consistently build indexes to go along with Primary Keys, or at > least that's the error message I have been getting. I am far from > confident in my own sqlfu in the catalog tables. Does anyone have a > script for identifying tables without indexes that correspond to their > PKs? I'm just trying to avoid re-inventing the wheel if I can help it. Here's an example for you... begin; create schema foo; set search_path to foo; create table haspk (a int primary key); create table missingpk (a int); select relname from pg_class c join pg_namespace n on c.relnamespace = n.oid where nspname = 'foo' and relkind = 'r' and c.oid not in ( select conrelid from pg_constraint where contype = 'p' ); abort; HTH > > Thanks, > > John > > > John P Weatherman > Sr Database Administrator > Centerstone -- Jerry Sievers Postgres DBA/Development Consulting e: gsievers19@comcast.net p: 305.321.1144