Re: [PERFORM] Postgres does not use indexes with OR-conditions

2014-11-07 Thread David G Johnston
Kevin Grittner-5 wrote > Andrew Dunstan < > andrew@ > > wrote: >> On 11/07/2014 12:06 AM, Vlad Arkhipov wrote: > >>> I need to rewrite it in the way below to make Postgres use the index. >>> >>> select * >>> from commons.financial_documents fd >>> where fd.creation_time <= '2011-11-07 10:39:07.2

Re: [PERFORM] Postgres does not use indexes with OR-conditions

2014-11-07 Thread Tom Lane
Kevin Grittner writes: > On the other hand, why not simply write it as?: > select * > from commons.financial_documents fd > where (fd.creation_time, fd.financial_document_id) > < ('2011-11-07 10:39:07.285022+08', 100) > order by fd.creation_time desc > limit 200 That's the way to d

Re: [PERFORM] Postgres does not use indexes with OR-conditions

2014-11-07 Thread Kevin Grittner
Andrew Dunstan wrote: > On 11/07/2014 12:06 AM, Vlad Arkhipov wrote: >> I need to rewrite it in the way below to make Postgres use the index. >> >> select * >> from commons.financial_documents fd >> where fd.creation_time <= '2011-11-07 10:39:07.285022+08' >> and ( >>fd.creation_time < '2011

Re: [PERFORM] Postgres does not use indexes with OR-conditions

2014-11-07 Thread Andrew Dunstan
On 11/07/2014 12:06 AM, Vlad Arkhipov wrote: It was just a minimal example. The real query looks like this. select * from commons.financial_documents fd where fd.creation_time < '2011-11-07 10:39:07.285022+08' or (fd.creation_time = '2011-11-07 10:39:07.285022+08' and fd.financial_document_i

Re: [PERFORM] Postgres does not use indexes with OR-conditions

2014-11-06 Thread Vlad Arkhipov
It was just a minimal example. The real query looks like this. select * from commons.financial_documents fd where fd.creation_time < '2011-11-07 10:39:07.285022+08' or (fd.creation_time = '2011-11-07 10:39:07.285022+08' and fd.financial_document_id < 100) order by fd.creation_time desc limit

Re: [PERFORM] Postgres does not use indexes with OR-conditions

2014-11-06 Thread David Rowley
On Fri, Nov 7, 2014 at 5:16 PM, arhipov wrote: > Hello, > > I have just came across interesting Postgres behaviour with OR-conditions. > Are there any chances that the optimizer will handle this situation in the > future? > > select * > from commons.financial_documents fd > where fd.creation_time

[PERFORM] Postgres does not use indexes with OR-conditions

2014-11-06 Thread arhipov
Hello, I have just came across interesting Postgres behaviour with OR-conditions. Are there any chances that the optimizer will handle this situation in the future? select * from commons.financial_documents fd where fd.creation_time <= '2011-11-07 10:39:07.285022+08' order by fd.creation_time