pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: lutzeb@aeccom.com
Cc: Greg Stark <gsstark@mit.edu>
Cc: pgsql-performance@postgresql.org
Cc: john@arbash-meinel.com
Subject: Re: query produces 1 GB temp file
Date: Sun, 06 Feb 2005 12:16:54 -0500
Message-ID: <4859.1107710214@sss.pgh.pa.us> (raw)
In-Reply-To: <42061B35.6000306@aeccom.com>
References: <20050205182117.0125074@mail2.aeccom.com>
	<87y8e2kb8j.fsf@stark.xeocode.com>
	<42061B35.6000306@aeccom.com>

Dirk.Lutzebaeck@t-online.de (Dirk Lutzebaeck) writes:
> SELECT DISTINCT ON (df.val_9, df.created, df.flatid) df.docindex, 
> df.flatobj, bi.oid, bi.en
> FROM bi,df
> WHERE bi.rc=130170467
> ...
> ORDER BY df.val_9 ASC, df.created DESC
> LIMIT 1000 OFFSET 0

Just out of curiosity, what is this query supposed to *do* exactly?
It looks to me like it will give indeterminate results.  Practical
uses of DISTINCT ON generally specify more ORDER BY columns than
there are DISTINCT ON columns, because the extra columns determine
which rows have priority to survive the DISTINCT filter.  With the
above query, you have absolutely no idea which row will be output
for a given combination of val_9/created/flatid.

			regards, tom lane



view thread (24+ messages)  latest in thread

Message-ID: <4859.1107710214@sss.pgh.pa.us>
Permalink:  ../4859.1107710214@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4859.1107710214@sss.pgh.pa.us

 · 

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-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lutzeb@aeccom.com, gsstark@mit.edu, john@arbash-meinel.com
  Subject: Re: query produces 1 GB temp file
  In-Reply-To: <4859.1107710214@sss.pgh.pa.us>

* 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