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 1lNhlo-0008L6-2X for pgsql-general@arkaria.postgresql.org; Sat, 20 Mar 2021 20:00:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNhll-0001ZD-9T for pgsql-general@arkaria.postgresql.org; Sat, 20 Mar 2021 20:00:21 +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 1lNhlk-0001YL-Rc for pgsql-general@lists.postgresql.org; Sat, 20 Mar 2021 20:00:21 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lNhlh-0002NH-0U for pgsql-general@lists.postgresql.org; Sat, 20 Mar 2021 20:00:19 +0000 Received: by mail-ej1-x629.google.com with SMTP id u5so14996994ejn.8 for ; Sat, 20 Mar 2021 13:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=xo16J6iKGTUsYb9aCTC9CmfeY5tcopo+nBcpUurDRe8=; b=tAbPa1jDx0yl/+U2wUfyVHlMhIOTXrq7Q8FrDjHpC6X0SgQzOg2YRaTOEqi4f17KTF zd17STL568IS3HXkx6J+KWUYrlYcEdJ75cGrZShefmksAJAbzi4MLNBFoekTLKrtTYvC aXWhfwcul/1uW0xn4wOb4IiaTvu+Bd34/mlh3BXtcKb8z54pbLaO1XmQ7doAq3KPvujA 8lFJ9t7YfwVRkZiCLofymdKSqYt4o6S5b8C3jhPbQJKscyVzaXLfUTwEpEP5JRsPljRi WbSQvIC0wgHyVhF+W6EGu+loJ+T44B5MHy5EYLqteD3Ae4NO0trZx04HZieByJymzq+t h9Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=xo16J6iKGTUsYb9aCTC9CmfeY5tcopo+nBcpUurDRe8=; b=pTIs5PpWt9HZzVCc6JLm57WQWhrscSRFtkj0wvuE/ASuoKgdTAcu/b3hRJVtAhh4nF L0xQN5+X0kck9y9uZSIOIpZof20L0qHCXsmyJQlrFduvGW3KalZLwR/Hxd4dZw8WdbdR 8la4hPckBva98Em84k1ipXB0zW653mDR67a31EL4iGeI0ROZtSm+GTj4x7ynRjb87t92 T785lNgQTdjEG3XkLxIBoySIazsVDdEh5N3SlEiqFd9+0qOBmsOtwas/rbWyf3Mm4no8 oIoHoWhgUAu5n5cfbbRwFNMIhQZn5sorgY/B7ydn3Tn/t8+bo41HSHIF3iW9FQVzy7kH FQ/g== X-Gm-Message-State: AOAM532lvqJ0B/9ySKQNlXJaH0Ufygabpt2yp5gIVmCr4SzAO+nRpHJQ VSqVLuRZhzJMSTmgQ4QrJz+siIdmYYM3oQ== X-Google-Smtp-Source: ABdhPJycRP3+VzAQhKx1aBKJzJVz5ET9atWd75ZkGBLqZp1EEK41HOmk6aUpgO/qyoFhnDdjIThv5w== X-Received: by 2002:a17:906:5e50:: with SMTP id b16mr11427683eju.272.1616270414530; Sat, 20 Mar 2021 13:00:14 -0700 (PDT) Received: from localhost.localdomain (62-46-250-177.adsl.highway.telekom.at. [62.46.250.177]) by smtp.gmail.com with ESMTPSA id p27sm5650492eja.79.2021.03.20.13.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Mar 2021 13:00:14 -0700 (PDT) Message-ID: <7d1d877d122bc59dceddd687f37fb674175078dd.camel@cybertec.at> Subject: Re: More than one UNIQUE key when matching items.. From: Laurenz Albe To: Ron Clarke , pgsql-general@lists.postgresql.org Date: Sat, 20 Mar 2021 21:00:13 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 2021-03-20 at 15:51 +0000, Ron Clarke wrote: > In SQL Server this is easy, we insert the records into a temporary table with separate Unique > indexes on the id for set a and the ids for set b and put the 'ignore_dup_key' on which tells > SQL Server to ignore duplicate rows and carry on. > > The nearest to this at first appears to be the ON CONFLICT ON CONSTRAINT IGNORE in Postgres. > But this only works with a single constraint, at a time i.e. we can't set the ON CONFLICT ON > CONSTRAINT IGNORE to work with multiple UNIQUE indexes. You can try this: INSERT ... ON CONFLICT DO NOTHING; Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com