Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 869A59FB1BA for ; Wed, 31 Jan 2007 10:19:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 99173-05 for ; Wed, 31 Jan 2007 10:19:44 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from bay0-omc3-s39.bay0.hotmail.com (bay0-omc3-s39.bay0.hotmail.com [65.54.246.239]) by postgresql.org (Postfix) with ESMTP id 6DEF69FA4D3 for ; Wed, 31 Jan 2007 10:19:44 -0400 (AST) Received: from hotmail.com ([65.55.137.92]) by bay0-omc3-s39.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Wed, 31 Jan 2007 06:19:42 -0800 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 31 Jan 2007 06:19:42 -0800 Message-ID: Received: from 65.55.137.123 by by132fd.bay132.hotmail.msn.com with HTTP; Wed, 31 Jan 2007 14:19:41 GMT X-Originating-IP: [200.91.71.251] X-Originating-Email: [sidarlopez@hotmail.com] X-Sender: sidarlopez@hotmail.com In-Reply-To: <81961ff50701301437t60c5370bvdf165215cbeaeb25@mail.gmail.com> From: =?iso-8859-1?B?U2lkYXIgTPNwZXogQ3J1eg==?= To: pgsql-performance@postgresql.org Cc: chad.wagner@gmail.com Subject: Re: Very slow queries Date: Wed, 31 Jan 2007 08:19:41 -0600 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed X-OriginalArrivalTime: 31 Jan 2007 14:19:42.0155 (UTC) FILETIME=[D970B9B0:01C74542] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/445 X-Sequence-Number: 23046 >From: "Chad Wagner" >To: "Sidar López Cruz" >CC: pgsql-performance@postgresql.org >Subject: Re: [PERFORM] Very slow queries >Date: Tue, 30 Jan 2007 17:37:17 -0500 > >On 1/30/07, Sidar López Cruz wrote: >> >>query: Delete From ceroriesgo.salarios Where numero_patrono Not In (Select >>numero_patrono From ceroriesgo.patronos) >> >>Seq Scan on salarios (cost=51021.78..298803854359.95 rows=14240077 >>width=6) >> Filter: (NOT (subplan)) >> SubPlan >> -> Materialize (cost=51021.78..69422.58 rows=1032980 width=25) >> -> Seq Scan on patronos (cost=0.00..41917.80 rows=1032980 >>width=25) >> > >How many rows exist in salarios, but not in patronos? How many rows are >there in salarios? Rows: Patronos: 1032980 Salarios: 28480200 > >What does the explain look like for: > >delete >from ceroriesgo.salarios s >where not exists (select 1 > from ceroriesgo.patronos > where numero_patrono = s.numero_patrono); > >Also, is this not a case for a foreign key with a cascade delete? No, this is not cascade delete case because I need to delete from salarios not from patronos. >http://www.postgresql.org/docs/8.2/static/ddl-constraints.html > > >-- >Chad >http://www.postgresqlforums.com/ _________________________________________________________________ Charla con tus amigos en línea mediante MSN Messenger: http://messenger.latam.msn.com/