Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E299C1337B54 for ; Tue, 19 Apr 2011 16:52:05 -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 85438-02 for ; Tue, 19 Apr 2011 19:51:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from web39702.mail.mud.yahoo.com (web39702.mail.mud.yahoo.com [209.191.106.48]) by mail.postgresql.org (Postfix) with SMTP id ABDAF1337B8B for ; Tue, 19 Apr 2011 16:51:47 -0300 (ADT) Received: (qmail 83095 invoked by uid 60001); 19 Apr 2011 19:51:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1303242705; bh=LwNLkM5j3orpxl53D+CmdJGQxN2sMaSwCd2Y14T5IJY=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=PApG2LLoYeIXc8CPLxUJqMCCno/AEdYAZVD7J3W6UDEV8m4w4Sfb0Ctjk9sgyzV8UbY7q9Znlys6Vnh6wrL4oMGOMDFcEO6MB9V6vmKguUASwBkqA3x0DjYy9qonPt4R8D1YlHdbwARCe/b18mlCug4tmXsBYteLCyLcwW8CNjI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=MCmWbeisWGPkXGC/fH9AMtNpRcWj1NAOd49OffhxIUcTkINn+jA389hGQ+q0GmejlPAhKO1WJnwp36/04PNk7Q1ibfGlOsZhQgBQEWRpAhxx9u2JlxAoDlvZBXqVRk4KB+zt2bZNrBG+Hf2QdHPSBITG7EMoVVUegkWR6d1Pz4k=; Message-ID: <594449.61680.qm@web39702.mail.mud.yahoo.com> X-YMail-OSG: WhREo7oVM1nz1xkieBijoUSAaCXMvNPZiaha1AjAwqQE3vC dsTkHZzEhWUF0ZRpxsDFcaU8vDKqw36Vcz3aLbVQDucpBdcZzL3Oc2wkirzD XRRCfzjWPxuqaXhJaxGLNG7WMr9UCVZqzgO4D_InbNEsQKIZZ5F7Bmt1LEs4 gu_rcrNXlOQcusaI5Gz_Mzmlki3dbn6FAc693IDCepRF3TNy61ul732xjz7y kyidxGL0H54WakWxtK.PgonA_iK9P9xWrp9sNYNpozgVsrosC9rkMcawDTVu jDmi2JCHN0nehBWauLIV_ByETFGWEFuTOGahkhUZQfpX_pb.D8xjKdU0a2k6 pKrZs7iK3CPzDt1JhC.pvS7Hv5X5.wtP7Osz8dFBA7ZSmJdXfZGF1UZW9V1g mX.xMgzcjMirv Received: from [64.126.29.122] by web39702.mail.mud.yahoo.com via HTTP; Tue, 19 Apr 2011 12:51:45 PDT X-Mailer: YahooMailClassic/12.0.2 YahooMailWebService/0.8.109.295617 Date: Tue, 19 Apr 2011 12:51:45 -0700 (PDT) From: Bob Lunney Subject: Re: PKs without indexes To: jweatherman91@alumni.wfu.edu, Jerry Sievers Cc: pgsql-admin@postgresql.org In-Reply-To: <8762qap8u2.fsf@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.908 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/178 X-Sequence-Number: 37359 =0A--- On Tue, 4/19/11, Jerry Sievers wrote:=0A=0A= > From: Jerry Sievers =0A> Subject: Re: [ADMIN] PKs= without indexes=0A> To: jweatherman91@alumni.wfu.edu=0A> Cc: pgsql-admin@p= ostgresql.org=0A> Date: Tuesday, April 19, 2011, 11:19 AM=0A> John P Weathe= rman =0A> writes:=0A> =0A> > Hi all,=0A> >=0A= > > I am attempting to set up slony-i and have run into a=0A> minor=0A> > g= litch...apparently whoever designed the database I=0A> have inherited=0A> >= didn't consistently build indexes to go along with=0A> Primary Keys, or at= =0A> > least that's the error message I have been=0A> getting.=A0 I am far = from=0A> > confident in my own sqlfu in the catalog tables.=A0=0A> Does any= one have a=0A> > script for identifying tables without indexes that=0A> cor= respond to their=0A> > PKs?=A0 I'm just trying to avoid re-inventing the=0A= > wheel if I can help it.=0A> =0A> Here's an example for you...=0A> =0A> be= gin;=0A> =0A> create schema foo;=0A> set search_path to foo;=0A> =0A> creat= e table haspk (a int primary key);=0A> create table missingpk (a int);=0A> = =0A> select relname=0A> from pg_class c=0A> join pg_namespace n on c.relnam= espace =3D n.oid=0A> where nspname =3D 'foo'=0A> and relkind =3D 'r'=0A> an= d c.oid not in (=0A> =A0 =A0 select conrelid=0A> =A0 =A0 from pg_constraint= =0A> =A0 =A0 where contype =3D 'p'=0A> );=0A> =0A> abort;=0A> =0A> HTH=0A= =0ASlony will use any unique index on a table for replication purposes, so = the list of tables should come from:=0A=0Aselect relname=0A from pg_class = c=0A join pg_namespace n on c.relnamespace =3D n.oid=0A where nspname =3D = current_schema()=0A and relkind =3D 'r'=0A and c.oid not in (=0A = select indrelid=0A from pg_index=0A where indisprimary or in= disunique=0A)=0A order by 1;=0A=0ABob Lunney=0A=0A