Re: On duplicate ignore

From: Atul Goel <Atul(dot)Goel(at)iggroup(dot)com>
To: "gnanam(at)zoniac(dot)com" <gnanam(at)zoniac(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: On duplicate ignore
Date: 2012-01-18 12:23:35
Message-ID: EFF68181B8966741827DCE10F20EAEF12B2B0847BC@PRDEXC101.igi.ig.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Just create a unique index on EMAIL column and handle error if it comes

Thanks,
Atul Goel

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Gnanakumar
Sent: 18 January 2012 11:04
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] On duplicate ignore

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

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

The information contained in this email is strictly confidential and for the use of the addressee only, unless otherwise indicated. If you are not the intended recipient, please do not read, copy, use or disclose to others this message or any attachment. Please also notify the sender by replying to this email or by telephone (+44 (0)20 7896 0011) and then delete the email and any copies of it. Opinions, conclusions (etc) that do not relate to the official business of this company shall be understood as neither given nor endorsed by it. IG Group Holdings plc is a company registered in England and Wales under number 04677092. VAT registration number 761 2978 07. Registered Office: Cannon Bridge House, 25 Dowgate Hill, London EC4R 2YA. Listed on the London Stock Exchange. Its subsidiaries IG Markets Limited and IG Index Limited are authorised and regulated by the Financial Services Authority (IG Markets Limited FSA registration number 195355 and IG Index Limited FSA registration number 114059).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ruben Blanco 2012-01-18 12:57:20 Partial index does not make query faster
Previous Message pittgs 2012-01-18 11:20:05 Redirect ERROR, FATAL and other messages