X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 63C0656793 for ; Tue, 22 Mar 2005 19:14:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41032-08 for ; Tue, 22 Mar 2005 19:14:41 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id CE88C56795 for ; Tue, 22 Mar 2005 19:14:40 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2MJEfo6011071; Tue, 22 Mar 2005 14:14:41 -0500 (EST) To: "Chris Hoover" Cc: "Sabio - PSQL" , "PostgreSQL Admin" Subject: Re: Too slow In-reply-to: <424068B0.8090101@sermonaudio.com> References: <42402A4B.70703@ceroriesgo.co.cr> <424068B0.8090101@sermonaudio.com> Comments: In-reply-to "Chris Hoover" message dated "Tue, 22 Mar 2005 13:49:20 -0500" Date: Tue, 22 Mar 2005 14:14:41 -0500 Message-ID: <11070.1111518881@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/356 X-Sequence-Number: 16854 "Chris Hoover" writes: > The "not in (subselect)" is very slow in postgresql. It's OK as long as the subselect result is small enough to hash, but with 5500000 rows that's not going to happen :-(. Another issue is that if there are any NULLs in the subselect then you will probably not like the results. They are correct per spec but not very intuitive. Personally I'd try ye olde outer join trick: select partes.* from partes left join sujetos on (identificacion = cedula) where cedula is null; A merge join on this would likely be the most effective solution. regards, tom lane