From: | Mike Christensen <mike(at)kitchenpc(dot)com> |
---|---|
To: | Arjen Nienhuis <a(dot)g(dot)nienhuis(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Query to get the "next available" unique suffix for a name |
Date: | 2010-09-28 07:58:34 |
Message-ID: | AANLkTim+d32BWngGYinsBD_FeaF3FtwChCf9vTJQ39_4@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Sep 28, 2010 at 12:44 AM, Arjen Nienhuis <a(dot)g(dot)nienhuis(at)gmail(dot)com> wrote:
>> 4) Do a SELECT on each row that starts with "MikeChristensen" and then
>> trying to append the row count to the end, this might not be exact but
>> it's somewhat intelligent as a starting point. However, this might
>> require some special indexes on this table to quickly scan rows that
>> start with a certain name. However, if I get to the point where this
>> becomes slow then I can worry about it at that point since this would
>> only be run on new account creation and not super speed critical.
>>
>
> CREATE TABLE test (a text PRIMARY KEY);
>
> INSERT INTO test (a)
> SELECT * FROM (SELECT 'MikeChristensen' || generate_series AS t FROM
> generate_series(1,10000)) x
> WHERE t NOT in (SELECT a FROM test) LIMIT 1 RETURNING *;
Now that's an interesting approach, I will play around with that - thanks!!
From | Date | Subject | |
---|---|---|---|
Next Message | Satoshi Nagayasu | 2010-09-28 09:28:04 | Re: ECPG - Some errno definitions don't match to the manual |
Previous Message | Arjen Nienhuis | 2010-09-28 07:44:34 | Re: Query to get the "next available" unique suffix for a name |