From: | Robert James <srobertjames(at)gmail(dot)com> |
---|---|
To: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Understanding sequential versus index scans. |
Date: | 2009-07-20 00:58:05 |
Message-ID: | e09785e00907191758r43a6187ja0b372a5a7547fc2@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is there anyway to tell Postgres "Run these two queries, and union their
results, but don't change the plan as to a UNION - just run them
separately"?
Something seems funny to me that running a UNION should be twice as slow as
running the two queries one after the other.
On Sun, Jul 19, 2009 at 8:10 PM, Robert James <srobertjames(at)gmail(dot)com>wrote:
> UNION was better, but still 5 times as slow as either query done
> individually.
> set enable_seqscan=off didn't help at all - it was totally ignored
> Is there anything else I can do?
>
> On Sun, Jul 19, 2009 at 7:47 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> Robert James <srobertjames(at)gmail(dot)com> writes:
>> > Hi. I notice that when I do a WHERE x, Postgres uses an index, and when
>> I
>> > do WHERE y, it does so as well, but when I do WHERE x OR y, it
>> > doesn't.
>>
>> It can use indexes for OR conditions, but not for arbitrary OR
>> conditions...
>>
>> > select * from dict
>> > where
>> > word in (select substr('moon', 0, generate_series(3,length('moon'))))
>> --
>> > this is my X above
>> > OR word like 'moon%' -- this is my Y above
>>
>> ... and that one is pretty arbitrary. You might have some luck with
>> using a UNION instead, viz
>>
>> select * from dict where X
>> union all
>> select * from dict where Y
>>
>> regards, tom lane
>>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2009-07-20 01:05:00 | Re: Understanding sequential versus index scans. |
Previous Message | Robert James | 2009-07-20 00:56:08 | Re: Should I CLUSTER on PRIMARY KEY |