Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZQ0l8-0001H0-9v for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Aug 2015 22:14:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZQ0l7-0000T9-6K for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Aug 2015 22:14:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZQ0l6-0000T2-KR for pgsql-hackers@postgresql.org; Thu, 13 Aug 2015 22:14:00 +0000 Received: from smtp-auth.no-ip.com ([8.23.224.61] helo=out.smtp-auth.no-ip.com) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZQ0l1-0007dC-Gb for pgsql-hackers@postgresql.org; Thu, 13 Aug 2015 22:13:59 +0000 X-No-IP: alvh.no-ip.org@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from alvin.alvh.no-ip.org (unknown [200.104.169.63]) (Authenticated sender: alvh.no-ip.org@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id 502544011BA; Thu, 13 Aug 2015 15:13:48 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 6E04F13BD; Thu, 13 Aug 2015 19:13:46 -0300 (CLT) Date: Thu, 13 Aug 2015 19:13:46 -0300 From: Alvaro Herrera To: Andres Freund Cc: pgsql-hackers@postgresql.org Subject: Re: [COMMITTERS] pgsql: Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE. Message-ID: <20150813221346.GH5232@alvherre.pgsql> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Andres Freund wrote: > This is implemented using a new infrastructure called "speculative > insertion". It is an optimistic variant of regular insertion that first > does a pre-check for existing tuples and then attempts an insert. If a > violating tuple was inserted concurrently, the speculatively inserted > tuple is deleted and a new attempt is made. If the pre-check finds a > matching tuple the alternative DO NOTHING or DO UPDATE action is taken. > If the insertion succeeds without detecting a conflict, the tuple is > deemed inserted. Is there a reason why heap_finish_speculative and heap_abort_speculative were made to take a HeapTuple rather than just an ItemPointer? They only use tuple->t_self in their code (except the former, which in an assert verifies that the tuple is indeed speculative). -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers