Query plan for NOT IN - Mailing list pgsql-performance

From Matthew Wakeling
Subject Query plan for NOT IN
Date
Msg-id alpine.DEB.2.00.0910051446450.19472@aragorn.flymine.org
Whole thread Raw
Responses Re: Query plan for NOT IN  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
List pgsql-performance
mnw21-modmine-r13features-copy=# select count(*) from project;
  count
-------
     10
(1 row)

mnw21-modmine-r13features-copy=# select count(*) from intermineobject;
   count
----------
  26344616
(1 row)

mnw21-modmine-r13features-copy=# \d intermineobject;
Table "public.intermineobject"
  Column |  Type   | Modifiers
--------+---------+-----------
  object | text    |
  id     | integer | not null
  class  | text    |
Indexes:
     "intermineobject_pkey" UNIQUE, btree (id)

mnw21-modmine-r13features-copy=# explain select * from project where id
NOT IN (SELECT id FROM intermineobject);
                                      QUERY PLAN
------------------------------------------------------------------------------------
  Seq Scan on project  (cost=1476573.93..1476575.05 rows=5 width=183)
    Filter: (NOT (hashed SubPlan 1))
    SubPlan 1
      ->  Seq Scan on intermineobject  (cost=0.00..1410720.74 rows=26341274 width=4)
(4 rows)

This query plan seems to me to be a little slow. Surely it could iterate
through the ten project rows and perform ten index lookups in the big
table?

Matthew

--
 Riker: Our memory pathways have become accustomed to your sensory input.
 Data:  I understand - I'm fond of you too, Commander. And you too Counsellor

pgsql-performance by date:

Previous
From: Csaba Nagy
Date:
Subject: Re: [OT] Best suiting OS
Next
From: Grzegorz Jaśkiewicz
Date:
Subject: Re: Query plan for NOT IN