From: Rong Wu <rwu@cbnco.com>
To: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: Thanks - Re: low cardinality column
Date: Thu, 2 Oct 2003 16:11:21 -0400 (EDT)
Message-ID: <33506.207.164.182.8.1065125481.squirrel@mail.cbnco.com> (raw)
In-Reply-To: <3F7C75C3.4060904@potentialtech.com>
References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com>
<1065120643.89807.40.camel@jester>
<3F7C75C3.4060904@potentialtech.com>
Thanks, Rod, Josh and Bill, That' fantastic.
have a nice day,
rong :-)
> 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 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: rwu@cbnco.com
Subject: Re: Thanks - Re: low cardinality column
In-Reply-To: <33506.207.164.182.8.1065125481.squirrel@mail.cbnco.com>
References: <33423.207.164.182.8.1065119401.squirrel@mail.cbnco.com> <1065120643.89807.40.camel@jester> <3F7C75C3.4060904@potentialtech.com> <33506.207.164.182.8.1065125481.squirrel@mail.cbnco.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