Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZ2VS-0002pK-Qb for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2017 21:31:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cZ2VR-0005FK-Px for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2017 21:31:57 +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 1cZ2VQ-0005Eg-Is for pgsql-hackers@postgresql.org; Wed, 01 Feb 2017 21:31:56 +0000 Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cZ2VJ-00033j-0z for pgsql-hackers@postgresql.org; Wed, 01 Feb 2017 21:31:55 +0000 Received: by mail-qt0-x22a.google.com with SMTP id k15so288097023qtg.3 for ; Wed, 01 Feb 2017 13:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=vbbnVCl/VcD/McBQTgMl7jNuUnxhIVLmLrGS39Sh+AI=; b=zWWJ6LDEL16f6vpQ2j64oyv2c0U33SLd5XqM1W3pqAtRU+635mE3Q9wyossHKtvTX5 ZOYVBzmjWzy4+FC5mrwy9gpVBL00qE++rw1Qf10tBnMf4rl6Y6st5240vpaAdmT5E65g l9oSjPXc73wa5BLhLQIJTHXIUsxqdKWu5QnXF96AyBWApvHnrdwwUHo3oDNXQ6/PhD5F MtWD5DV8C132BHdddpTProVVnNrM1Itf5YCS9dreQBIANGlKVmhpW1f47OPE7JPFRsMU 2ddXqfeDc17z4e+zdjT3u678tqETFoM+XXALicKZiyFoyLKAiKivU9q4/m5MYnR849Wb O0sw== 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:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=vbbnVCl/VcD/McBQTgMl7jNuUnxhIVLmLrGS39Sh+AI=; b=KFxukWM1VBcK7axkriJAgbgFII09g/wV0npXe7E0fNq6Qp05Izc1tVvD6HOV0EpkL2 k8ONJi6TriGottbuspQQrUvyf/kKifZMjE96ErKKc8RsgyDFsbGNh2EPJQfjRH+bzYAf 4b1rn5Qi+BiVL+P9tLsFzEs4ILpYlOZFbogXL0n78uhVX+obXkq+T9Q2/b7HE1uMcpZa jmu/pP6SyWeIcVwjnV1ZIfuiEdpGF0+7FI5QSilCEUCYYxGicjAp2HFPFaNTF1czrIit VZJ4u2OT1ojo5/Nt55bc7bsMHnsQrwXSChQLoqaIpI8v2GDx1StpolUWOWegRiWUSWDG pluw== X-Gm-Message-State: AMke39khTtCxgNB8JHV8ufknCBUah+iaP8/DYyT+Yz3ZvWB1f41RsgWPk/UufHObyUqrKqG7 X-Received: by 10.55.114.132 with SMTP id n126mr4970441qkc.112.1485984707410; Wed, 01 Feb 2017 13:31:47 -0800 (PST) Received: from alvin.alvh.no-ip.org ([179.57.112.237]) by smtp.gmail.com with ESMTPSA id 37sm19685147qto.43.2017.02.01.13.31.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 13:31:46 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 6A3C9E23; Wed, 1 Feb 2017 18:31:44 -0300 (CLST) Date: Wed, 1 Feb 2017 18:31:44 -0300 From: Alvaro Herrera To: Tom Lane Cc: Pavan Deolasee , pgsql-hackers Subject: Re: Patch: Write Amplification Reduction Method (WARM) Message-ID: <20170201213144.xb64zuem6azqntrs@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <27502.1485981379@sss.pgh.pa.us> User-Agent: NeoMutt/20170113 (1.7.2) 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 Tom Lane wrote: > The source of both of those problems is that in some places, we > did CatalogOpenIndexes and then used the CatalogIndexState for > multiple tuple inserts/updates before doing CatalogCloseIndexes. > The patch dealt with these either by not touching them, just > leaving the simple_heap_insert/update calls in place (thus failing > to create any abstraction), or by blithely ignoring the optimization > and doing s/simple_heap_insert/CatalogTupleInsert/ anyway. For example, > in inv_api.c we are now doing a CatalogOpenIndexes/CatalogCloseIndexes > cycle for each chunk of the large object ... and just to add insult to > injury, the now-useless open/close calls outside the loop are still there. Ouch. You're right, I missed that. > I think what we ought to do about this is invent additional API > functions, say > > Oid CatalogTupleInsertWithInfo(Relation heapRel, HeapTuple tup, > CatalogIndexState indstate); > void CatalogTupleUpdateWithInfo(Relation heapRel, ItemPointer otid, > HeapTuple tup, CatalogIndexState indstate); > > and use these in place of simple_heap_foo plus CatalogIndexInsert > in the places where this optimization had been applied. This looks reasonable enough to me. > An alternative but much more complicated fix would be to get rid of > the necessity for callers to worry about this at all, by caching > a CatalogIndexState in the catalog's relcache entry. That might be > worth doing eventually (because it would allow sharing index info > collection across unrelated operations) but I don't want to do it today. Hmm, interesting idea. No disagreement on postponing. -- Álvaro Herrera https://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