Re: Advice on implementing counters in postgreSQL

From: "Marco Bizzarri" <marco(dot)bizzarri(at)gmail(dot)com>
To: PgSQL-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Advice on implementing counters in postgreSQL
Date: 2008-08-03 07:47:21
Message-ID: 3f0d61c40808030047r11d824a7r3b0e8ade48f050c0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Aug 2, 2008 at 5:11 PM, David Fetter <david(at)fetter(dot)org> wrote:
> On Sat, Aug 02, 2008 at 09:23:31AM +0200, Marco Bizzarri wrote:
>> Hi all.
>>
>> I need to keep a numer of counters in my application; my counters
>> are currently stored in a table:
>>
>> name | next_value | year
>>
>> The counters must be progressive numbers with no holes in between
>> them, and they must restart from 1 every year.
>
> Here's a backward-compatible way to do this:
>
> http://www.varlena.com/GeneralBits/130.php
>
> Cheers,
> David.
> --
> David Fetter <david(at)fetter(dot)org> http://fetter.org/
> Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
> Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
>
> Remember to vote!
> Consider donating to Postgres: http://www.postgresql.org/about/donate
>

David, thanks for pointing me to such a complete solution.

These work both on READ-COMMITTED and SERIALIZABLE isolation levels, am I right?

Regards
Marco

--
Marco Bizzarri
http://iliveinpisa.blogspot.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marco Bizzarri 2008-08-03 07:50:21 Re: Advice on implementing counters in postgreSQL
Previous Message Manoj Patwardhan 2008-08-03 05:27:22 Re: Fresh install on Mac OS 10.5.4