Re: Changed to: how to solve the get next 100 records problem

From: PFC <lists(at)boutiquenumerique(dot)com>
To: Alain <alainm(at)pobox(dot)com>, Sql-Postgre <pgsql-sql(at)postgresql(dot)org>, Diogenes <di(at)sene(dot)info>
Subject: Re: Changed to: how to solve the get next 100 records problem
Date: 2005-05-18 17:52:14
Message-ID: op.sqzfxct8th1vuj@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php pgsql-sql

> The only strange thing is that without the 3rd order by, the order is
> wrong. I didn't expect it because each select is created ordered. Is it
> expected that UNION mixes it all up? (using postgre 7.4.1)

That's because UNION removes duplicates, which it will probably doing
using a hash (EXPLAIN ANALYZE is your friend).
Use UNION ALL because your WHERE condition allows no duplicates anyway.
UNION ALL preserves the order.
So you can get the LIMIT out of the subqueries and put it around the
UNION ALL.

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Ragnar Hafstað 2005-05-18 17:53:52 Re: Changed to: how to solve the get next 100 records problem
Previous Message Alain 2005-05-18 15:42:27 Changed to: how to solve the get next 100 records problem

Browse pgsql-sql by date

  From Date Subject
Next Message Ragnar Hafstað 2005-05-18 17:53:52 Re: Changed to: how to solve the get next 100 records problem
Previous Message Peter Bense 2005-05-18 17:40:50 Help with views/rules...