From: | "Rong Wu" <rwu(at)cbnco(dot)com> |
---|---|
To: | "Postgresql Performance" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Thanks - Re: low cardinality column |
Date: | 2003-10-02 20:11:21 |
Message-ID: | 33506.207.164.182.8.1065125481.squirrel@mail.cbnco.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
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
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Vivek Khera | 2003-10-02 20:16:58 | Re: inferior SCSI performance |
Previous Message | Bruno Wolff III | 2003-10-02 19:58:43 | Re: count(*) slow on large tables |