Thread

  1. [Keystone Slip # 19] NOT IN clause performs badly

    webmaster@postgresql.org — 1999-07-26T16:46:57Z

    ---------------------------------------------------------------------------
    Slip number -----: 19
    Problem ---------: NOT IN clause performs badly
    Opened by -------: Christian.Rudow@thinx.ch on 07/26/99 05:28
    Assigned To -----: momjian
    ---------------------------------------------------------------------------
    Summary:
    table a (id integer
             any number/type of other attributes)
    unique index on id.
    holding 10'000 rows
    
    table b (id integer)
    holding a subset of 8'000 rows, that
    exist in table a.
    
    trying to select all id values from table a
    that do nor exist in table b :
    
       select id from a
       where id not in (select id from b);
    
    this takes hours to process, while a simple join
    
       select id from a,b
       where a.id = b.id 
    
    returns within seconds
    
    explain says : sequential scan on a and b.
    still 120 minutes for processing can't be.
    
    system used :
    PG 6.4 on SusE 6.0, PII/300mhz.
    
    ---------------------------------------------------------------------------
    
    
              Full information on this slip is available at:
    http://www.postgresql.org/bugs/visitor.php3?sid=19&v_func=zoom
    
    ---------------------------------------------------------------------------
    This message was generated automatically by Keystone at http://www.postgresql.org