Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gf55S-0003bl-CH for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Jan 2019 15:39:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gf55Q-0006f2-On for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Jan 2019 15:39:08 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gf55Q-0006ev-Dz for pgsql-hackers@lists.postgresql.org; Thu, 03 Jan 2019 15:39:08 +0000 Received: from mail-it1-x144.google.com ([2607:f8b0:4864:20::144]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gf55M-0006cg-T4 for pgsql-hackers@postgresql.org; Thu, 03 Jan 2019 15:39:07 +0000 Received: by mail-it1-x144.google.com with SMTP id a6so43155630itl.4 for ; Thu, 03 Jan 2019 07:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=haZhTZcfejpLFlaANHglk6lkHZopO7N65852gC8Bta0=; b=ztinqM58QTxnaZirqP9pBmZK5im+1tN9J126tcrB30ZsuJIgFR0sdPz/6KExw2XgoV LBDXIeXgWDPiW9n3QCzi6cWYm6LHEU6xHVDf+sW2LisWouLm7wMCtI6KRiKgq1dv56iU xW/8K2YTxBvPSEG0geN5Wn2O1pxmkvi+TXwWjO5fRO+g7+tBOVjBU8iP7uAY3alQZPkn TQFl2k4IRV1eyvRtJZWc7oxDSB6z+clBx2S8YViGP8e/IhQ33txs/xHYBEUC2S+ZHAKO cuXo5+e9Z0DD6OcYbv03HVWBPAEivCK8TM7gKeMQd2jZLNUaRd9fjFf+EyKflwOAyraW c4aQ== 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=haZhTZcfejpLFlaANHglk6lkHZopO7N65852gC8Bta0=; b=LFDvYWioowhk0qSe8pXJBZUOhqPEiB3we/4uJ+sHNN+sPuKaha6o5wsuZiNBxHS8mx wWBocD/oFlbko2w7SlWWw7420qUeCuKj0fFFcMWwgO1WglMqt3HJoe9UhQ65GhK+A+td ZjJlVsLoFyzWRuQxl+NZpidp/xn0UVxVGbiP15Wx9eeNmqOwXDEewAv0wJyU3MqlOWIx 6J6IhagwZIGQ6xe4RtM0CM3p2puyG49iuBfJ6a4UDffyOvxT+OGXtEhPMKJijhFdHnZM hEAuIQhZ2/bxfX8zGxCqpcjEiqDBl9HOKxGf0z93mVY/DRJ07482w4AhKWv3WL618x2Y b7Kg== X-Gm-Message-State: AA+aEWY0CBbVWOPiAizt6M40gpqSF+Juz0bYNFyf1vGn1DzLH/8IHBNL fz4YlkOo5hIPI+Q5KbXhLW1APQ== X-Google-Smtp-Source: AFSGD/Xaki1dPWq7EHU08ROwu/m8egRxxp7nctnGfk5cci0V9FiuGi1VMY0O0BQeWuB9kV6PuVZUpg== X-Received: by 2002:a24:9307:: with SMTP id y7mr31766964itd.38.1546529942660; Thu, 03 Jan 2019 07:39:02 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id q23sm10216812iog.63.2019.01.03.07.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Jan 2019 07:39:02 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id 04954800A7E; Thu, 3 Jan 2019 09:39:00 -0600 (CST) Date: Thu, 3 Jan 2019 09:39:00 -0600 From: Justin Pryzby To: Amit Langote Cc: "Imai, Yoshikazu" , David Rowley , Alvaro Herrera , pgsql-hackers@postgresql.org Subject: Re: speeding up planning with partitions Message-ID: <20190103153900.GA6236@telsasoft.com> References: <3be67028-a00a-502c-199a-da00eec8fb6e@lab.ntt.co.jp> <73596f90-023c-c358-be9a-3c21bffcb15d@lab.ntt.co.jp> <0F97FA9ABBDBE54F91744A9B37151A5122E7B1@g01jpexmbkw24> <08a6775f-7c88-81a8-8c2c-984d171b6db9@lab.ntt.co.jp> <0F97FA9ABBDBE54F91744A9B37151A51232FF7@g01jpexmbkw24> <0F97FA9ABBDBE54F91744A9B37151A5124C0A0@g01jpexmbkw24> <580ddb99-cd31-096d-d485-fc309d274498@lab.ntt.co.jp> <55bd88c6-f311-2791-0a36-11c693c69753@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55bd88c6-f311-2791-0a36-11c693c69753@lab.ntt.co.jp> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, I don't think I can't help with code review, but I loaded our largest customer's schema into pg12dev and tested with this patch. It's working well - thanks for your work. Details follow. We have tooo many tables+indices so this vastly improves planning speed. Our large customers have ~300 parent tables and total ~20k child tables with total ~80k indices. Our largest tables heirarchies have ~1200 child tables, which may have as many as 6-8 indices each. And 5-10 of the largest heirarchies are unioned together in a view. Running pg11.1, explaining query for the largest view with condition eliminates all but today's tables can take several minutes with a cold cache, due to not only stat()ing every file in every table in a partition heirarchy, before pruning, but also actually open()ing all their indices. Running 11dev with your v10 patch applied, this takes 2244ms with empty buffer cache after postmaster restarted on a totally untuned instance (and a new backend, with no cached opened files). I was curious why it took even 2sec, and why it did so many opens() (but not 20k of them that PG11 does): [pryzbyj@database postgresql]$ cut -d'(' -f1 /tmp/strace-12dev-explain |sort |uniq -c |sort -nr 2544 lseek 1263 open ... It turns out 1050 open()s are due to historic data which is no longer being loaded and therefor never converted to relkind=p (but hasn't exceeded the retention interval so not yet DROPped, either). Cheers, Justin