On Mon, Jan 12, 2004 at 20:24:10 -0600,
"D. Dante Lorenso" <dante@lorenso.com> wrote:
>
> See what I mean? What do you propose as the best solution for this?
> Not expose
> the sequences to the user and use user-enumerated ids? Then a trigger
> on the
> table would assign ids like:
>
> SELECT (MAX(widget_id)+1) INTO NEW.widget_id
> WHERE cust_id = NEW.cust_id;
>
> But I think after several hundred customer records, this trigger would start
> getting slow. I don't know really, any ideas?
I think it would be better to have a per customer counter. Then the GID
would be customer, customer_sequence. You probably wouldn't want to use
postgres sequences for this. I would expect that generating new ID numbers
isn't so common that updating a counter row in a customer counter table
would be a real problem.