Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eALYT-00071d-9o for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 19:53:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eALYS-0006ZP-Sx for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 19:53:32 +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 1eALWr-0000SH-9m for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 19:51:53 +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 1eALWo-0007px-HV for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 19:51:52 +0000 Received: by mail-pg0-x232.google.com with SMTP id g6so519125pgn.6 for ; Thu, 02 Nov 2017 12:51:49 -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=BmnS0AnMCcQK1Q2GubKJBeTupxBLIBWn+nFnZS/pHIQ=; b=J+oGyl+bsIwgd3331ABhX9vZnAMataRc7b8S3NdWw2VFTbMVqDE70yycXpEVBvSF/h Nyox8fmGqtfXVUAmLHQySwP6IFXPwnd6M8alxvcLEKtQ1YjCSN1ZPB9xFQmdF/FUoHPQ voDFf6qrY8sdYvpYUaxXkrixP37ITSa8cJNR7yiTfEE6M546lWa/S8o94B+F8WxHXiib SUXKENviK216QqU5AskKfxIanzQj2xcZvqZ2hV2V/WVOYJgoNa480Mu3VEFQ8SWjmnnU 4AC2Q7l6wMHHV1kCOdhITW/eWZrst+qjaYWZUNSVJpJuvxKASKUQEV+1b/HDlr1mLldU nLZg== 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=BmnS0AnMCcQK1Q2GubKJBeTupxBLIBWn+nFnZS/pHIQ=; b=Yt+jVBTeuVPpeVIqFIswUF5eZvLYnpOWiGKfWTW0founDGiXfSfgr/hY7YRXGS/wsa 3hnBc27oW2CdBuaVk4EjX+DrtB9+1/fFHQirSEqgIwrPizBXPyabddh13Z8Z7qDscGWG wB3zFj2DZOz/+zFpkDXEaBrrm8o759ILIFFrQX+gYdyBRN2qrVsJJO7VqN5LG8HWI7Mq W2H2j8Lv2cC5LO6J9Y85oK7c+mXSUy8JZtlg72x1Cn+U1AtrsOv31iBa1vL2AIeFsf6p +xbacASQq3ctOEJJ0ak+vkJcULXiKg34V2pLHIS+IXtrsaxU8odqt/ocUsCzBIt7Fb3O 4MKA== X-Gm-Message-State: AMCzsaVQfw7i0Ccndksql/ij4y9aaAfbwXhffQmVK+wqIq2udA8zoaff UijiD2v6kov/3rsesIhddBrnPiT1r9E= X-Google-Smtp-Source: ABhQp+StSa0fQMvcRkH/oPEBDk2qayZiFC5oZjoZ9FnmTVwpS0PRUdtEStJimTYwIgcA3HjqYXT1bA== X-Received: by 10.98.17.7 with SMTP id z7mr5076293pfi.206.1509652308371; Thu, 02 Nov 2017 12:51:48 -0700 (PDT) Received: from marmot ([162.217.72.7]) by smtp.gmail.com with ESMTPSA id n72sm7990958pfi.92.2017.11.02.12.51.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 12:51:47 -0700 (PDT) Date: Thu, 2 Nov 2017 12:51:45 -0700 From: Peter Geoghegan To: Nico Williams Cc: Simon Riggs , Robert Haas , Michael Paquier , PostgreSQL-development Subject: Re: MERGE SQL Statement for PG11 Message-ID: <20171102195145.GB27644@marmot> References: <20171101182032.GA7104@marmot> <20171102191612.GR4496@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20171102191612.GR4496@localhost> 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 Nico Williams wrote: >If you want to ignore conflicts arising from concurrency you could >always add an ON CONFLICT DO NOTHING to the INSERT DML in the mapping I >proposed earlier. Thus a MERGE CONCURRENTLY could just do that. > >Is there any reason not to map MERGE as I proposed? Performance, for one. MERGE generally has a join that can be optimized like an UPDATE FROM join. I haven't studied this question in any detail, but FWIW I think that using CTEs for merging is morally equivalent to a traditional MERGE implementation. It may actually be possible to map from CTEs to a MERGE statement, but I don't think that that's a good approach to implementing MERGE. Most of the implementation time will probably be spent doing things like making sure MERGE behaves appropriately with triggers, RLS, updatable views, and so on. That will take quite a while, but isn't particularly technically challenging IMV. -- 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