Search Postgresql Archives

Re: Query to get the "next available" unique suffix for a name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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 *;

Groeten, Arjen

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux