Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kuZUp-0007CV-8m for pgsql-admin@arkaria.postgresql.org; Wed, 30 Dec 2020 11:18:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kuZUn-00069Q-HH for pgsql-admin@arkaria.postgresql.org; Wed, 30 Dec 2020 11:18:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kuZUn-00069J-9b for pgsql-admin@lists.postgresql.org; Wed, 30 Dec 2020 11:18:25 +0000 Received: from [85.214.83.89] (helo=rs.plausibolo.de) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kuZUg-0002Rt-Dr for pgsql-admin@lists.postgresql.org; Wed, 30 Dec 2020 11:18:24 +0000 Received: from localhost (localhost [127.0.0.1]) by rs.plausibolo.de (Postfix) with ESMTP id 8A6C83805B8; Wed, 30 Dec 2020 12:18:07 +0100 (CET) Received: from rs.plausibolo.de ([IPv6:::1]) by localhost (h2367442.stratoserver.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id hahU4Vhp0uoM; Wed, 30 Dec 2020 12:18:07 +0100 (CET) Received: from [192.168.178.197] (ip-37-201-154-46.hsi13.unitymediagroup.de [37.201.154.46]) by rs.plausibolo.de (Postfix) with ESMTPSA id 405D43804D2; Wed, 30 Dec 2020 12:18:07 +0100 (CET) Subject: Re: how to make duplicate finding query faster? To: pgsql-admin@lists.postgresql.org References: <5bf642e4-eb22-8eba-e96d-5b33b5010b03@jakobs.com> From: Holger Jakobs Message-ID: Date: Wed, 30 Dec 2020 12:18:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QZc3fHxVDhrHH78z9tyZN15OavFPhnx58" X-Host-Lookup-Failed: Reverse DNS lookup failed for 85.214.83.89 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QZc3fHxVDhrHH78z9tyZN15OavFPhnx58 Content-Type: multipart/mixed; boundary="v5CJJ4zGuQFWbopshr39htXHz0kOb5Xv3"; protected-headers="v1" From: Holger Jakobs To: pgsql-admin@lists.postgresql.org Message-ID: Subject: Re: how to make duplicate finding query faster? References: <5bf642e4-eb22-8eba-e96d-5b33b5010b03@jakobs.com> In-Reply-To: --v5CJJ4zGuQFWbopshr39htXHz0kOb5Xv3 Content-Type: multipart/alternative; boundary="------------BF26C08AD99B5EC5B0299B0E" Content-Language: de-DE This is a multi-part message in MIME format. --------------BF26C08AD99B5EC5B0299B0E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Am 30.12.20 um 09:59 schrieb Sachin Kumar: > HI Mr. Holger, > > This will not suffice our requirement. we have to validate that there=20 > would=C2=A0not be any duplicate value in DB. we have done that earlier = by=20 > leaving DB to check if there is any duplicate and found duplicate=20 > value in DB. > > we have a table "card"=C2=A0 and a single column "number " which we are= =20 > updated with a csv file with 600k numbers and require no duplicate=20 > number should=C2=A0be there in the table. > > Please if can have a faster query can help us in achieving=C2=A0this=20 > requirement. > > Quote: leaving DB to check if there is any duplicate and found duplicate = value in DB No, that's not possible with PostgreSQL. If you have a Primary Key or a=20 Unique Constraint, no duplicates will be allowed by the DB. There must be a different reason. --=20 Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012 --------------BF26C08AD99B5EC5B0299B0E Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Am 30.12.20 um 09:59 schrieb Sachin Kumar:
HI Mr. Holger,

This will not suffice our requirement. we have to validate that there would=C2=A0not be any duplicate value in DB. we have= done that earlier by leaving DB to check if there is any duplicate and found duplicate value in DB.=C2=A0

we have a table "card"=C2=A0 and a single column "number " w= hich we are updated with a csv file with 600k numbers and require no duplicate number should=C2=A0be there in the table.

Please if can have a faster query can help us in achieving=C2=A0this requirement.


Quote: leaving DB to check if there is any duplicate and found duplicate value in DB

No, that's not possible with PostgreSQL. If you have a Primary Key or a Unique Constraint, no duplicates will be allowed by the DB.

There must be a different reason.


--=20
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
--------------BF26C08AD99B5EC5B0299B0E-- --v5CJJ4zGuQFWbopshr39htXHz0kOb5Xv3-- --QZc3fHxVDhrHH78z9tyZN15OavFPhnx58 Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wmMEABEIACMWIQScuJCxWJK1p5BOebGKV5yTsxlhugUCX+xh7gUDAAAAAAAKCRCKV5yTsxlhuj/O AJoDbPJpSa5V26Dev4RSJ9gtdqwJZwCg23UPT/0bWq5mfzjh/BFX48WsdtQ= =0u7/ -----END PGP SIGNATURE----- --QZc3fHxVDhrHH78z9tyZN15OavFPhnx58--