pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrus Moor <eetasoft@online.ee>
To: pgsql-sql@postgresql.org
Subject: Query runs very slowly in Postgres, but very fast in other DBMS
Date: Tue, 12 Apr 2005 00:43:10 +0300
Message-ID: <d3er3k$2m2d$1@news.hub.org> (raw)

Tables:

CREATE TABLE dok ( dokumnr NUMERIC(12),
            CONSTRAINT dok_pkey PRIMARY KEY (dokumnr) );
CREATE TABLE rid ( dokumnr NUMERIC(12) );
CREATE INDEX rid_dokumnr_idx ON rid (dokumnr);

Query:

SELECT dokumnr FROM rid WHERE dokumnr NOT IN
(select dokumnr FROM dok);

runs VERY slowly in Postgres. It uses the following query plan:

Seq Scan on rid  (cost=0.00..28698461.07 rows=32201 width=14)
  Filter: (NOT (subplan))
  SubPlan
    ->  Seq Scan on dok  (cost=0.00..864.29 rows=10729 width=14)

In Microsoft Visual FoxPro this query runs fast. FoxPro uses indexes speed 
up the query by comparing bitmaps.

Is it possible to speed up this query is Postgres ? How to force Postgres to 
use indexes for this query ?

Andrus 





view thread (6+ messages)  latest in thread

Message-ID: <d3er3k$2m2d$1@news.hub.org>
Permalink:  ../d3er3k$2m2d$1@news.hub.org/
Also on:    postgresql.org/message-id/d3er3k$2m2d$1@news.hub.org

 · 

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-sql@postgresql.org
  Cc: eetasoft@online.ee
  Subject: Re: Query runs very slowly in Postgres, but very fast in other DBMS
  In-Reply-To: <d3er3k$2m2d$1@news.hub.org>

* 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