Re: Performance implications of creating many, many sequences

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Performance implications of creating many, many sequences
Date: 2010-10-22 19:50:26
Message-ID: 4CC1EB02.60709@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Is this "invoice_number" just an id or what might appear an a bill (in
some pretty form etc)?

If the former, just get a unique id over all invoices. At the very
least it will save time i) in writing where clauses ii) re-creating the
correct id once some one assigns an invoice to the wrong customer.

On 10/22/2010 01:18 PM, Michael Gardner wrote:
> Consider the following table:
>
> CREATE TABLE invoice (
> account_id integer NOT NULL REFERENCES account,
> invoice_number integer NOT NULL,
> UNIQUE (account_id,invoice_number));
>
> I would like to do the equivalent of making invoice_number a serial type, but on a per-account basis. Would it be a reasonable approach to create a separate sequence for each individual account? Are there performance implications I should know about, given that there will be hundreds of thousands of accounts? Is there another approach I should be looking at instead?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Gardner 2010-10-22 20:01:53 Re: Performance implications of creating many, many sequences
Previous Message Michael Gardner 2010-10-22 19:18:34 Performance implications of creating many, many sequences