pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marius Andreiana <mandreiana@rdslink.ro>
To: pgsql-performance@postgresql.org
Subject: NOT IN query takes forever
Date: Tue, 03 Aug 2004 11:49:02 +0300
Message-ID: <1091522942.4936.5.camel@marte.biciclete.ro> (raw)

Hi

I have 2 tables like this:
CREATE TABLE query (
	query_id 	int not null,
	dat 	varchar(64)  null ,
	sub_acc_id 	int  null ,
	query_ip 	varchar(64)  null ,
	osd_user_type 	varchar(64)  null 
)
;

CREATE TABLE trans (
	transaction_id 	varchar(64)  not null ,
	date 	varchar(64)  null ,
	query_id 	int not  null ,
	sub_acc_id 	int  null ,
	reg_acc_id 	int  null 
)
;

CREATE UNIQUE INDEX query_query_id_idx
ON query (query_id)
;

CREATE INDEX trans_reg_acc_id_idx
ON trans (reg_acc_id)
;

CREATE INDEX trans_query_id_idx
ON trans(query_id)
;
osd=> select count(*) from trans
osd-> ;
 count
--------
 598809
(1 row)
 
osd=>
osd=> select count(*) from query
osd-> ;
 count
--------
 137042
(1 row)

I just vacuum analyse'd the database. 

Trying to run this query:
EXPLAIN ANALYSE
select * FROM trans
WHERE query_id NOT IN (select query_id FROM query)

but it will remain like that forever (cancelled after 30 min).

My postgresql.conf is the default:
# - Memory -
 
shared_buffers = 1000           # min 16, at least max_connections*2,
8KB each
#sort_mem = 1024                # min 64, size in KB
#vacuum_mem = 8192              # min 1024, size in KB

Should I adjust something?

Using postgresql 7.4.2, saw in release notes that IN/NOT IN queries are
at least as faster than EXISTS.

Thank you!
-- 
Marius Andreiana
Galuna - Solutii Linux in Romania
http://www.galuna.ro




view thread (10+ messages)  latest in thread

Message-ID: <1091522942.4936.5.camel@marte.biciclete.ro>
Permalink:  ../1091522942.4936.5.camel@marte.biciclete.ro/
Also on:    postgresql.org/message-id/1091522942.4936.5.camel@marte.biciclete.ro

 · 

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: mandreiana@rdslink.ro
  Subject: Re: NOT IN query takes forever
  In-Reply-To: <1091522942.4936.5.camel@marte.biciclete.ro>

* 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