Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-phppgsql-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

pgsql-php by date

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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group