From: Bill Moran <wmoran@potentialtech.com>
Cc: rwu@cbnco.com, Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Re: low cardinality column
Date: Thu, 02 Oct 2003 15:00:19 -0400
Message-ID: <3F7C75C3.4060904@potentialtech.com> (raw)
In-Reply-To: <1065120643.89807.40.camel@jester>
References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com>
<1065120643.89807.40.camel@jester>
Rod Taylor wrote:
> On Thu, 2003-10-02 at 14:30, Rong Wu wrote:
>
>>Hi,
>>
>>I have a select like this:
>>
>>SELECT MAX(transactionid) FROM cbntransaction WHERE transactiontypeid=0;
>
>
> For various reasons (primarily MVCC and the ability to make custom
> aggregates making it difficult) MAX() is not optimized in this fashion.
>
> Try:
>
> SELECT transactionid
> FROM ...
> WHERE ...
> ORDER BY transactionid DESC
> LIMIT 1;
Despite this good suggestion, if you're using this technique to generate
the next transaction ID, you're going to have errors as concurrency rises.
Use a SERIAL, which guarantees that you won't have two processes generate
the same number.
--
Bill Moran
Potential Technologies
http://www.potentialtech.com
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: wmoran@potentialtech.com
Subject: Re: low cardinality column
In-Reply-To: <3F7C75C3.4060904@potentialtech.com>
* 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