Re: PostgreSQL Gotchas

From: Ian Barwick <barwick(at)gmail(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Jeffrey Melloy <jmelloy(at)visualdistortion(dot)org>, Neil Conway <neilc(at)samurai(dot)com>, "Aly S(dot)P Dharshi" <aly(dot)dharshi(at)telus(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL Gotchas
Date: 2005-10-07 06:14:27
Message-ID: 1d581afe0510062314j69a1771ai67e7dd0e373a567@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/7/05, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
> On Thu, Oct 06, 2005 at 05:47:36PM -0500, Jeffrey Melloy wrote:
> > The only thing I could see actually being an issue is the random() one
> > and add missing from. The rest are trivial. The random() thing is
> > interesting, esoteric, and probably has never been a problem in a real
> > situation. (Or has exactly once, when he wrote that gotcha)
>
> The random() issue has a workaround that the gotchas page doesn't
> mention:
>
> SELECT id, is_true
> FROM (SELECT id, RANDOM() < 0.5 AS is_true FROM some_table OFFSET 0) AS t_tmp
> WHERE is_true;
>
> Tom Lane brought up the OFFSET 0 trick a couple of days ago in the
> "Avoiding evaluating functions twice" thread:
>
> http://archives.postgresql.org/pgsql-general/2005-10/msg00107.php

Thanks, I've updated the list.

I'd like to take the opportunity to point out that following the
original, unexpected "success" of the MySQL gotchas list, I created
one for PostgreSQL for the sake of "balance". Though I'm really having
to scrape the barrel for material ;-).

The MySQL list is a little outdated; I'm going through it with updates
for version 5.

Ian Barwick

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ilja Golshtein 2005-10-07 07:35:28 SELECT FOR SHARE
Previous Message Ian Barwick 2005-10-07 05:38:52 Re: PostgreSQL 8.1 vs. MySQL 5.0?