Re: [PERFORM] Slow query with indexed ORDER BY and LIMIT when using OR'd conditions

2014-07-22 Thread johno
> > No, it doesn't. Read it again ... or read up on row comparisons, > if you're unfamiliar with that notation. The above queries are > exactly equivalent per spec. > Wow, this is great. Thanks.

Re: [PERFORM] Slow query with indexed ORDER BY and LIMIT when using OR'd conditions

2014-07-21 Thread Tom Lane
johno writes: > On Tue, Jul 22, 2014 at 4:53 AM, Tom Lane wrote: >> johno writes: >>> The obvious query is >>> SELECT * FROM register_uz_accounting_entities >>> WHERE effective_on > '2014-07-11' OR (effective_on = '2014-07-11' AND >>> id > 1459) >>> ORDER BY effective_on, id >>> LIMIT 100 >> A

Re: [PERFORM] Slow query with indexed ORDER BY and LIMIT when using OR'd conditions

2014-07-21 Thread johno
On Tue, Jul 22, 2014 at 4:53 AM, Tom Lane wrote: > johno writes: > > I am trying to optimize a simple query that returns first 100 rows that > > have been updated since a given timestamp (ordered by timestamp and id > > desc). If there are several rows with the same timestamp I need to a > > se

Re: [PERFORM] Slow query with indexed ORDER BY and LIMIT when using OR'd conditions

2014-07-21 Thread Tom Lane
johno writes: > I am trying to optimize a simple query that returns first 100 rows that > have been updated since a given timestamp (ordered by timestamp and id > desc). If there are several rows with the same timestamp I need to a > second condition, that states that I want to return rows having

[PERFORM] Slow query with indexed ORDER BY and LIMIT when using OR'd conditions

2014-07-21 Thread johno
Hi there, I am trying to optimize a simple query that returns first 100 rows that have been updated since a given timestamp (ordered by timestamp and id desc). If there are several rows with the same timestamp I need to a second condition, that states that I want to return rows having the given t