From: Jeremiah Elliott <jelliott@artcobell.com>
To: pgsql-performance@postgresql.org
Subject: slow query - where not in
Date: Fri, 28 Mar 2003 09:38:50 -0600
Message-ID: <200303280938.50382.jelliott@artcobell.com> (raw)
here is the query that is killing me:
select shoporder from sodetailtabletrans where shoporder not in(select
shoporder from soheadertable)
This is just an example query. Any time I use 'where not in(' it takes several
hours to return a resultset. The postgres version is 7.2.3 although I have
tried it on my test server which has 7.3 on it and it runs just as slow. The
server is a fast server 2GHz with a gig of ram. I have tried several
differant index setups but nothing seems to help.
soheadertable - 5104 rows
CREATE TABLE "soheadertable" (
"shoporder" numeric(10,0) NOT NULL,
"initrundate" date,
"actualrundate" date,
"processedminutes" numeric(10,0),
"starttime" timestamptz,
"endtime" timestamptz,
"line" int4,
"personcount" numeric(10,0),
"product" varchar(15),
"qtytomake" numeric(10,3),
"linestatus" numeric(2,0) DEFAULT 1,
"finishlinestatus" numeric(2,0) DEFAULT 1,
"qtyinqueue" numeric(10,3),
"lastcartonprinted" numeric(10,0),
"qtydone" int8,
"warehouse" text,
"rescheduledate" date,
"calculateddatetorun" date
);
CREATE UNIQUE INDEX "shoporder_soheadertable_ukey" ON "soheadertable"
("shoporder");
sodetailtabletrans - 31494 rows
CREATE TABLE "sodetailtabletrans" (
"shoporder" numeric(10,0) NOT NULL,
"soseq" numeric(5,0) NOT NULL,
"product" char(15) NOT NULL,
"qtyqueued" numeric(17,2),
"qtyneeded" numeric(17,2),
"qtyallocated" numeric(17,2),
"qtyused" numeric(17,2),
"linestatus" numeric(2,0) DEFAULT 1,
"unitsperenditem" numeric(10,1),
CONSTRAINT "sodetailtrans_pk" PRIMARY KEY ("shoporder", "soseq")
-Jeremiah Elliott
jelliott@artcobell.com
);
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: jelliott@artcobell.com
Subject: Re: slow query - where not in
In-Reply-To: <200303280938.50382.jelliott@artcobell.com>
References: <200303280938.50382.jelliott@artcobell.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