| From: | Joseph Shraibman <jks(at)selectacast(dot)net> |
|---|---|
| To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, pgsql-performance(at)postgresql(dot)org |
| Subject: | Re: two seperate queries run faster than queries ORed together |
| Date: | 2004-03-22 19:40:04 |
| Message-ID: | 405F4114.5070602@selectacast.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
Stephan Szabo wrote:
> On Mon, 22 Mar 2004, Joseph Shraibman wrote:
>
>
>>Tom Lane wrote:
>>
>>>Joseph Shraibman <jks(at)selectacast(dot)net> writes:
>>>
>>>
>>>>No, pkey is not the primary key in this case. The number of entries in u
>>>>that have pkey 260 and not boolfield is 344706.
>>>
>>>
>>>... and every one of those rows *must* be included in the join input,
>>
>>*If* you use one big join in the first place. If postgres ran the query
>>to first get the values with status == 3 from u, then ran the query to
>>get the entries from d, then combined them, the result would be the same
>>but the output faster. Instead it is doing seq scans on both tables and
>
>
> Well, you have to be careful on the combination to not give the wrong
> answers if there's a row with u.status=3 that matches a row d.status=3.
Right you would have to avoid duplicates. The existing DISTINCT code
should be able to handle that.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2004-03-22 20:44:09 | Re: two seperate queries run faster than queries ORed |
| Previous Message | Stephan Szabo | 2004-03-22 19:32:30 | Re: two seperate queries run faster than queries ORed |