pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christian Compagnon <ccompagnon@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Query take 101 minutes, help, please
Date: Wed, 7 Sep 2005 12:22:27 -0400
Message-ID: <d20db5e605090709227c2c3596@mail.gmail.com> (raw)

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=19406.67..62126112.70 rows=24731 width=13)
  Filter: (NOT (subplan))
   SubPlan
       ->  Materialize  (cost=19406.67..21576.07 rows=136740 width=13)
        ->  Unique  (cost=17784.23..18467.93 rows=136740 width=13)
        ->  Sort  (cost=17784.23..18126.08 rows=136740 width=13)
                                                               Sort
Key: "Rut Cliente"
          ->  Append  (cost=0.00..3741.80 rows=136740 width=13)
          ->  Subquery Scan "*SELECT* 1"  (cost=0.00..1233.38
rows=45069 width=13)
           ->  Seq Scan on "Internet_Enero"  (cost=0.00..782.69
rows=45069 width=13)
           ->  Subquery Scan "*SELECT* 2"  (cost=0.00..1104.06
rows=40353 width=13)
             ->  Seq Scan on "Internet_Febrero"  (cost=0.00..700.53
rows=40353 width=13)
           ->  Subquery Scan "*SELECT* 3"  (cost=0.00..1404.36
rows=51318 width=13)
            ->  Seq Scan on "Internet_Marzo"  (cost=0.00..891.18
rows=51318 width=13)

Any help will be apreciated, It's for my thesis


saludos
Christian



view thread (5+ messages)  latest in thread

Message-ID: <d20db5e605090709227c2c3596@mail.gmail.com>
Permalink:  ../d20db5e605090709227c2c3596@mail.gmail.com/
Also on:    postgresql.org/message-id/d20db5e605090709227c2c3596@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: ccompagnon@gmail.com
  Subject: Re: Query take 101 minutes, help, please
  In-Reply-To: <d20db5e605090709227c2c3596@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox