Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAMhj-0006gv-Q7 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 21:07:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eAMhj-0004ky-9b for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 21:07:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eAMg3-0001D6-Uk for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 21:05:28 +0000 Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1eAMg1-0000yN-1h for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 21:05:26 +0000 Received: by mail-pg0-x232.google.com with SMTP id m18so657251pgd.13 for ; Thu, 02 Nov 2017 14:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xDavcyS1Zp2hKx5BQpV9iqtjGV57LB5mz41gj1WRGFo=; b=h0i00/951Mhn9qmYPRmfXze5xrWNiE+SzcmcQrhlTbZyfY5kpj7uiRNGfA3M9MskJL /dCiEug7Dc3adZSxdxnYDz2bU8myD1zidp4LXrxDu+n1wznCfV6/DEzflb5CoQx0lV8J n4s6cxLTIh9Sx0W1uJZgck9yiAukP/WD4d8H8W5MfO+5aIgnVaRz7YCllU3E0gtgdDBO AT5BsK44VX7exidlfHAcdlHTET38NFeAv4PhFpG5XJD49A2dPpm/8KffyytXcgLdc9PK j+oaVZ8Ma9odIoj6l8B/k6/HP/0caWYntg1j7Dsi8GKvQRfrXeXWNqFWuJXHcOJBIciV T/pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xDavcyS1Zp2hKx5BQpV9iqtjGV57LB5mz41gj1WRGFo=; b=VRY7EPOKKEeqvbw4D6mC3dI3bTYxGUYjt9tpsCUGma4/BGBC/l7D6VKVNV6v+5Z7uw rPhbmgs1WcRAfwfExUEfiqO1ZBGExDKH9eXG+oxuyGQkU8AmSlHULjDb271KCrvMr/qd 86JbsXQxeQTLDHOn6xYadSzPYwPl/glaQYFAo4mw7eSFGiRJ+WiZvo9vwIsAD5ee5jsv LZMqhuAZFFPryvazzzoT/RFa0UwwjZ5nvRHNv30OYIlKQDcmpIxcXQQL/Ht3ghL/8DQ7 PeMjlAX9shNXgkHuxiP6kW2nftPchRARyPUVgfnLtlf+ScTdithtZ2qx8dzvwln9fop6 KaEg== X-Gm-Message-State: AMCzsaV2yz0oNbSh/IcwFTFbLZzrTd4GHiIkPxCn7hNO1u2sytSl7S8S 1c1868A6ZcI4lMwTtiDgLmm7RA== X-Google-Smtp-Source: ABhQp+R0r8GBi0sZjl/D3s0KAhGjZpBfQ9MDwGzbLyZ1IdQyK9zLATIPS242WqHP88N6yIQFB5j9Jg== X-Received: by 10.84.128.73 with SMTP id 67mr4471891pla.96.1509656722415; Thu, 02 Nov 2017 14:05:22 -0700 (PDT) Received: from marmot ([162.217.72.7]) by smtp.gmail.com with ESMTPSA id u188sm6745178pfb.188.2017.11.02.14.05.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 14:05:21 -0700 (PDT) Date: Thu, 2 Nov 2017 14:05:19 -0700 From: Peter Geoghegan To: Simon Riggs Cc: Robert Haas , Michael Paquier , PostgreSQL-development Subject: Re: MERGE SQL Statement for PG11 Message-ID: <20171102210519.GA31574@marmot> References: <20171101182032.GA7104@marmot> <20171102191636.GA27644@marmot> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) 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 Simon Riggs wrote: >I think people imagined you had worked out how to make MERGE run >concurrently, I certainly did, but in fact you're just saying you >don't believe it ever should. I'm certain that they didn't think that at all. But I'll let them speak for themselves. >That is strange since the SQL Standard specifically allows the >implementation to decide upon concurrent behaviour. And yet nobody else decided to do what you propose with this apparent leeway. (See the UPSERT wiki page for many references that confirm this.) >So in your view we should make no attempt to avoid concurrent errors, >even when we have the capability to do so (in some cases) and doing so >would be perfectly compliant with the SQLStandard. Yes. That's what I believe. I believe this because I can't see a way to do this that isn't a mess, and because ON CONFLICT DO UPDATE exists and works well for the cases where we can do better in READ COMMITTED mode. Did you know that Oracle doesn't have an EPQ style mechanism at all? Instead, it rolls back the entire statement and retries it from scratch. That is not really any further from or closer to the standard than the EPQ stuff, because the standard doesn't say anything about what should happen as far as READ COMMITTED conflict handling goes. My point here is that all of the stuff I'm talking about is only relevant in READ COMMITTED mode, in areas where the standard never provides us with guidance. If you can rely on SSI, then there is no difference between what you propose and what I propose anyway, except that what I propose is more general and will have better performance, especially for batch MERGEs. If READ COMMITTED didn't exist, implementing ON CONFLICT would have been more or less free of controversy. >Yes, that certainly will make an easier patch for MERGE. Indeed, it will. -- Peter Geoghegan -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers