Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAaey-00GbLW-9U for pgsql-general@arkaria.postgresql.org; Mon, 11 Nov 2024 20:05:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tAaev-0007Bv-Di for pgsql-general@arkaria.postgresql.org; Mon, 11 Nov 2024 20:05:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAaeu-0007Bn-Uw for pgsql-general@lists.postgresql.org; Mon, 11 Nov 2024 20:05:13 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tAaer-001PqM-TK for pgsql-general@lists.postgresql.org; Mon, 11 Nov 2024 20:05:12 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-431688d5127so38216185e9.0 for ; Mon, 11 Nov 2024 12:05:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20230601.gappssmtp.com; s=20230601; t=1731355509; x=1731960309; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=z2CrVu6aCprhj9Ed0iODGvAWmQj3DsE+fVQHdU0lEDc=; b=QhDjKmi7l/z2HnHHHO0qdrgSVzs2N9v1FyQeE6lViUJMtBP1NIutggzndpecWGvRFF MZMWQBG80vwRs7FWCl9WMJp9umum22SDx0e+ERFWJbO5HFeDZ8nfnJCva4Q0WwbfqENa j7+wp04BomWRjMlw7UkOQd1t1+G0ZrH47keLNw7hTCUm5hFD4kTopXL1A4SXSOcabHQn wRPcEwaA8K95g/7vjgRhxbxTBUWe0ojnYpxLDXheWlckLiaa+WAwSuhkckbV2xDKdxpS ExTDZBkd9lZ4/IX8A6ncXDkU1mFjlwke9quVu1zttXYRsAy86xVmq8yoElEZwuBnMu2r PuBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731355509; x=1731960309; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z2CrVu6aCprhj9Ed0iODGvAWmQj3DsE+fVQHdU0lEDc=; b=JKjwr8JxDat3VfNIiLVRsluSeA1A9ubdFKw3aNJg6BN6L1N3kMMX1QjSjf7KcNP6ih M992NXJpjkIdwEqE55eSz/SfUWOuXlAsr5W7SagyOWX+I9+MhiEiLBEYOjGuOhKMeB/z 0Ny4VqK75z/MrMksUyT+1s5CIImhc4Lf+Dk2i+UCbJhaziHJ315Jn9qqych3y+Hbgam8 iuTFavDKY52i+/RTlTxc8Ijq/s3XbsBa5ySfPX7fjAehl6D+IUGD64wiJ8oqzRSXXUXe w+NRJi4uRTxNc5+Tzf72JmZ8rORtfvEuzdV9bgzjxwwzPCHAfZzWmtfZdVuYdDsAHXv7 fpgA== X-Gm-Message-State: AOJu0YxwO/DsUXigEy8TLe57MZxKk6vTXgdUoNtLBeMgxxQpV7802a0V /vQAz+a5rH47XMunGwBdC8Dyv3MpllPoseFey2CbhWYy/PPjvyzR7pNJeY05q20tnXMbiwtn4y2 +jejPNFoaDxa8lUxYcgehsF/eyCwWMpiP/OKHaw== X-Google-Smtp-Source: AGHT+IEs0b0UyKkO/McY9xBpdztc2TCi14T0QMghwOVQ6ryI2xJUdaNGchW5FHl1uvFXhy7bgJkKT2XFs62xZOjyRfY= X-Received: by 2002:a05:600c:3ca4:b0:42c:a6da:a149 with SMTP id 5b1f17b1804b1-432b751839dmr123500325e9.25.1731355508980; Mon, 11 Nov 2024 12:05:08 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Peter Geoghegan Date: Mon, 11 Nov 2024 15:04:43 -0500 Message-ID: Subject: Re: Duplicate key error To: yudhi s Cc: pgsql-general Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Nov 11, 2024 at 12:41=E2=80=AFAM yudhi s wrote: > So it means it will ensure no duplication happens for ID values, but stil= l we are seeing "duplicate key" error. So what is the possible reason here = or are we encountering any buggy behaviour here? MERGE doesn't actually make any promises about not getting unique violations. Only ON CONFLICT DO UPDATE (and ON CONFLICT DO NOTHING) make such a promise. That's the main reason why Postgres supports both. --=20 Peter Geoghegan