pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PFC <lists@boutiquenumerique.com>
To: Alain <alainm@pobox.com>
To: Sql-Postgre <pgsql-sql@postgresql.org>
To: Diogenes <di@sene.info>
Subject: Re: Changed to: how to solve the get next 100 records problem
Date: Wed, 18 May 2005 19:52:14 +0200
Message-ID: <op.sqzfxct8th1vuj@localhost> (raw)
In-Reply-To: <20050517170636.GC12405@phlogiston.dyndns.org>
References: <DCD4903594CCF34CAFE200BDF3448D8D5B291A@tshuscodenmbx01.ERF.THOMSON.COM>
	<20050517170636.GC12405@phlogiston.dyndns.org>
	<428A2E81.2060501@pobox.com>
	<1116353539.26520.5.camel@localhost.localdomain>
	<428A3B54.4070902@pobox.com>
	<1116367382.9362.11.camel@localhost.localdomain>
	<428AA569.3010708@pobox.com>
	<1116404906.9362.19.camel@localhost.localdomain>
	<428B6263.5050402@pobox.com>



> 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.



view thread (3+ messages)  latest in thread

Message-ID: <op.sqzfxct8th1vuj@localhost>
Permalink:  ../op.sqzfxct8th1vuj@localhost/
Also on:    postgresql.org/message-id/op.sqzfxct8th1vuj@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: lists@boutiquenumerique.com, alainm@pobox.com, di@sene.info
  Subject: Re: Changed to: how to solve the get next 100 records problem
  In-Reply-To: <op.sqzfxct8th1vuj@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox