pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <rbt@rbt.ca>
To: Andreas Pflug <Andreas.Pflug@web.de>
Cc: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: SELECT DISTINCT is picky about constants
Date: 04 Feb 2003 09:29:13 -0500
Message-ID: <1044368952.80167.6.camel@jester> (raw)
In-Reply-To: <3E3FAEF2.5080302@web.de>
References: <3E3FAEF2.5080302@web.de>

On Tue, 2003-02-04 at 07:15, Andreas Pflug wrote:
> The query
>     SELECT DISTINCT keycol, 'constant' FROM myTable
> or
>     SELECT DISTINCT keycol, NULL FROM myTable
> 
> will result in an error message (7.3.1)
> 
> Unable to identify an ordering operator '<' for type "unknown"
> Use explicit ordering operator or modify query
> 
> If I use 'constant'::varchar or NULL::varchar everything's fine. 
> Unfortunately, this SELECT DISTINCT will appear quite often in my app.
> 
> I'd rather like PostgreSQL to use implicit type casting for such 
> constants. The final type chosen doesn't matter anyway and life would be 
> easier.

How about:

SELECT keycol, NULL FROM (SELECT DISTINCT keycol FROM myTable) AS tab;

Might even be quicker as you won't have to do any comparisons against
the constant.

-- 
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

Attachments:

  signature.asc (application/pgp-signature, 186B) download

view thread (2+ messages)

Message-ID: <1044368952.80167.6.camel@jester>
Permalink:  ../1044368952.80167.6.camel@jester/
Also on:    postgresql.org/message-id/1044368952.80167.6.camel@jester

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: rbt@rbt.ca, Andreas.Pflug@web.de
  Subject: Re: SELECT DISTINCT is picky about constants
  In-Reply-To: <1044368952.80167.6.camel@jester>
  References: <3E3FAEF2.5080302@web.de> <1044368952.80167.6.camel@jester>

* 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