Re: IN Qeury Problem

From: Wei Weng <wweng(at)kencast(dot)com>
To: maggon(at)newgen(dot)co(dot)in
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: IN Qeury Problem
Date: 2003-04-17 18:30:27
Message-ID: 3E9EF2C3.2000705@kencast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

What about this?

Put all those integers into a table called TempData

CREATE TABLE TempData
(
datavalue INTEGER;
);

CREATE INDEX ind_tempdata ON TEMPDATA (datavalue);

Then you can use query

SELECT * FROM FolderTable as ft, TempData as td
WHERE ft.ParentFolderIndex = td.datavalue;

IN query's performance has been notoriously bad in PostgreSQL
implementation, try to avoid it.

Regards,

Wei

Sameer Maggon wrote:

>Hello,
>
> I am facing a problem regarding the performance of postgres. I am
>concerned about the speed of the execution of a query when large number of
>entries is given in the IN clause.
>
>I have a Table with columns:
>
>FolderName (Indexed)
>FolderIndex (Indexed)
>ParentFolderIndex (Indexed)
>...
>..
>
>I have a query where i do a SELECT
>
>SELECT * FROM FolderTable WHERE PARENTFOLDERINDEX IN (38::int8, ......);
>
>If the number of values in IN clause is small, its working fine, but as and
>when the number of values increases the speed of the query is detoriating
>with a steep curve.
>
>How can this problem be solved ?
>
>Thanks and Regards
>Sameer Maggon
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>
>
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David Goodwin 2003-04-17 19:08:14 Re: reversion? Recursion question
Previous Message Randall Lucas 2003-04-17 18:01:25 Ordinal value of row within set returned by a query?