On duplicate ignore

From: "Gnanakumar" <gnanam(at)zoniac(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: On duplicate ignore
Date: 2012-01-18 11:04:28
Message-ID: 019901ccd5d0$f4a1cca0$dde565e0$@com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Ours is a web-based application. We're trying to implement ON DUPLICATE
IGNORE for one of our application table, named EMAILLIST. After a quick
Google search, I'm finding the following "easy & convenient" single SQL
statement syntax to follow with:

INSERT INTO EMAILLIST (EMAIL)
SELECT 'john(at)example(dot)net'
WHERE NOT EXISTS (SELECT 1 FROM EMAILLIST WHERE EMAIL =
'john(at)example(dot)net');

My question is, in a single threaded INSERT, this will *definitely* work.
Since ours is a web-based application, will this work out in a concurrent
multi-threaded environment too? In other words, will it be truly unique
when INSERT calls are concurrent?

Regards,
Gnanam

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Volodymyr Kostyrko 2012-01-18 11:11:55 scenario with a slow query
Previous Message Jasen Betts 2012-01-18 10:46:50 Re: Appending a newline to a column value - in a psql cronjob