From: | "Tomasz Myrta" <jasiek(at)klaster(dot)net> |
---|---|
To: | "James Cooper" <jim(at)luckydigital(dot)com>, "sql" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: INTERSECT / where id IN (etc..) |
Date: | 2003-03-05 23:39:53 |
Message-ID: | 20030306073953.M77564@klaster.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> Greetings.
>
> I was wondering if somone out there could shed some light on a query
> performance issie I have. I have a large lookup table that I query
> with nested selects to gain the INTERSECT result from.
>
> the bigger this table gets the slower the performance.
>
> 1. is creating a temp table and only intersecting from this a good idea?
>
> 2. does having a where clause in your select before your nested
> intersects change the amount of work the query
>
> i.e. select person_id from person where person_id < 5000 And
> person_id IN as opposed to select person_id from person where
> person_id IN(etc)
>
> thoughts?
person_id<5000 probably won't help - postgres will use index on exact
person_id if possible.
Anyway - for large queries try change IN (...) into EXISTS (...), or just
into explicit join if possible. IN clause is rather slow for bigger amount of
data.
Regards,
Tomasz Myrta
From | Date | Subject | |
---|---|---|---|
Next Message | James Cooper | 2003-03-06 00:54:50 | INTERSECT / where id IN (etc..) |
Previous Message | speakeasy | 2003-03-05 19:59:33 | View - Join based on dis-similar data types |