Karsten Hilbert wrote:
>>// check if entry already exists
>>SELECT COUNT(*) FROM tablename WHERE [cond]
>>
>>
>You may want to try this instead:
>
> select exists(select * from tablename where [cond])
>
>which should be faster than count(*). You'll get back a
>boolean value, though, not an integer.
>
>Karsten
>
>
Why not do:
SELECT 1 FROM tablename WHERE [cond];
And use row_count > 0 to determine a hit.
And I can't think of a way to prevent the race-condition thing besides
using SERIALIZABLE ISOLATION.