X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9AC0CD781C for ; Wed, 7 Sep 2005 13:22:34 -0300 (ADT) 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 69959-08 for ; Wed, 7 Sep 2005 16:22:30 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.207]) by svr1.postgresql.org (Postfix) with ESMTP id CF03AD77C0 for ; Wed, 7 Sep 2005 13:22:28 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id z31so2745470nzd for ; Wed, 07 Sep 2005 09:22:27 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Zop+D+F0RCiXPvVoGAyWrV5s03NNAySiHq4VGzuP63ZsYmX19duOfumDRjH2JrsZWRhOntjCVoaOekYIIR2SdqVwDpzC5OLFZOVWpDvVoZNTjNp+yzSxC9hexkQgWm/o/6ekqoC5qyeol8gy7B1j0fBxqJnN28wpKc17vsW1KlI= Received: by 10.36.25.13 with SMTP id 13mr3650924nzy; Wed, 07 Sep 2005 09:22:27 -0700 (PDT) Received: by 10.36.22.17 with HTTP; Wed, 7 Sep 2005 09:22:27 -0700 (PDT) Message-ID: Date: Wed, 7 Sep 2005 12:22:27 -0400 From: Christian Compagnon To: pgsql-performance@postgresql.org Subject: Query take 101 minutes, help, please Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 required=5 tests=[RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200509/109 X-Sequence-Number: 14417 Hello, I'm a newbie in postgresql, I've installed it on a Windows XP machine ( I can't use linux, it's a company machine ), I'm courious why this query takes so long SELECT "Rut Cliente" FROM "Internet_Abril" WHERE "Rut Cliente" NOT IN ((SELECT "Rut Cliente" FROM "Internet_Enero") UNION (SELECT "Rut Cliente" FROM "Internet_Febrero") UNION (SELECT "Rut Cliente" FROM "Internet_Marzo")); it takes about 100 minutes to complete the query. All tables has index created ( Rut Cliente is a VarChar ), and tables has 50.000 records each. The explain for the query tells the following "QUERY PLAN Seq Scan on "Internet_Abril" (cost=3D19406.67..62126112.70 rows=3D24731 w= idth=3D13) Filter: (NOT (subplan)) SubPlan -> Materialize (cost=3D19406.67..21576.07 rows=3D136740 width=3D13= ) -> Unique (cost=3D17784.23..18467.93 rows=3D136740 width=3D13) -> Sort (cost=3D17784.23..18126.08 rows=3D136740 width=3D13) Sort Key: "Rut Cliente" -> Append (cost=3D0.00..3741.80 rows=3D136740 width=3D13) -> Subquery Scan "*SELECT* 1" (cost=3D0.00..1233.38 rows=3D45069 width=3D13) -> Seq Scan on "Internet_Enero" (cost=3D0.00..782.69 rows=3D45069 width=3D13) -> Subquery Scan "*SELECT* 2" (cost=3D0.00..1104.06 rows=3D40353 width=3D13) -> Seq Scan on "Internet_Febrero" (cost=3D0.00..700.53 rows=3D40353 width=3D13) -> Subquery Scan "*SELECT* 3" (cost=3D0.00..1404.36 rows=3D51318 width=3D13) -> Seq Scan on "Internet_Marzo" (cost=3D0.00..891.18 rows=3D51318 width=3D13) Any help will be apreciated, It's for my thesis saludos Christian