Re: Big IN() clauses etc : feature proposal

From: Christian Kratzer <ck-lists(at)cksoft(dot)de>
To: PFC <lists(at)peufeu(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-performance(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Big IN() clauses etc : feature proposal
Date: 2006-05-09 09:01:00
Message-ID: 20060509105214.P90693@vesihiisi.cksoft.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

Hi,

On Tue, 9 May 2006, PFC wrote:
<snipp/>
> Back to the point : I can't use the temp table method, because temp
> tables are too slow.
> Creating a temp table, filling it, analyzing it and then dropping it
> takes about 100 ms. The search query, on average, takes 10 ms.

just some thoughts:

You might consider just selecting your primary key or a set of
primary keys to involved relations in your search query. If you
currently use "select *" this can make your result set very large.

Copying all the result set to the temp. costs you additional IO
that you propably dont need.

Also you might try:

SELECT * FROM somewhere JOIN result USING (id)

Instead of:

SELECT * FROM somewhere WHERE id IN (SELECT id FROM result)

Joins should be a lot faster than large IN clauses.

Here it will also help if result only contains the primary keys
and not all the other data. The join will be much faster.

On the other hand if your search query runs in 10ms it seems to be fast
enough for you to run it multiple times. Theres propably no point in
optimizing anything in such case.

Greetings
Christian

--
Christian Kratzer ck(at)cksoft(dot)de
CK Software GmbH http://www.cksoft.de/
Phone: +49 7452 889 135 Fax: +49 7452 889 136

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message PFC 2006-05-09 09:33:42 Re: Big IN() clauses etc : feature proposal
Previous Message PFC 2006-05-09 08:38:17 Big IN() clauses etc : feature proposal

Browse pgsql-performance by date

  From Date Subject
Next Message Hannes Dorbath 2006-05-09 09:16:45 Arguments Pro/Contra Software Raid
Previous Message PFC 2006-05-09 08:38:17 Big IN() clauses etc : feature proposal