Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gA5hF-0006wh-Es for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Oct 2018 04:02:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gA5hD-0006ef-VJ for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Oct 2018 04:02:03 +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.89) (envelope-from ) id 1gA5hC-0006e6-7u for pgsql-hackers@lists.postgresql.org; Wed, 10 Oct 2018 04:02:03 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gA5h8-0000P4-5G for pgsql-hackers@postgresql.org; Wed, 10 Oct 2018 04:02:01 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id AD5C821F35; Wed, 10 Oct 2018 00:01:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 10 Oct 2018 00:01:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=fW42q8PIb6nhIYRcYhXUsC5n2LT 6YFwH81tWgrXpfvw=; b=U414UV6wO5q2hzsktXDhkZBr4oVQXYoXX79cBP/3TOB uSBVZmUuAcCns18zYfDkJ+3OgFjqbiBt8A2sUObTXuhyqp9L6ARTH8DTgY/cOoAU eNeEeosZoO3dxwUSyMPEz5jr87Kwc/OOzPyN8Jp65hrrbAGkq7kBQ9GSvzHmtEtE TlPfCiI9HX4YLQylYn4U4AClFlfN9g1V+sO905HXJ4mNzmm/MqxqRNbwHvOfp1fe HkD2UOn/nLfBnoJpnNjbDT6TINi3bVHiyVGv1JaoMmWxHgtRewwCP1TnlFIl3Llf 4QgelhHFroyIc/DInJRl+YjAZWtR9aHwBJRPEmBtvTg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=fW42q8 PIb6nhIYRcYhXUsC5n2LT6YFwH81tWgrXpfvw=; b=KjwLmcT2URdLWZcB8U1zyJ ly0qPxSzPnGFv2nKsaUdVbofNtQKj2AE3xBIq1EPCugxhmqm5mjH9m2LKhqDU89e InHUr9ACjb2IjEMWGuX79bEmQSI5uWd4nsGzh1VR7QaVgHQZqirBrPn51cwxPjDM Jcbe+i7QVdPd6b2UQyBL/yHFuZNUfo66u6p5VIszGtOmfwr/8qz4WJLw+KBt5ryB Eow0tA5Rk+gcCIkRDqknsY1DO4OhSf2CXWVLrAWMvrYB9uhFwAHJa/4WPgakcAcF T6/ax35oG5SjpQNw02Qo/YW+o1JdlyIrEPFxGgPGHK5RP3zxuz0E4/5uKuiLheFw == X-ME-Sender: X-ME-Proxy: Received: from paquier.xyz (mp76f1f94f.ap.nuro.jp [118.241.249.79]) by mail.messagingengine.com (Postfix) with ESMTPA id AAF79102E9; Wed, 10 Oct 2018 00:01:53 -0400 (EDT) Date: Wed, 10 Oct 2018 13:01:50 +0900 From: Michael Paquier To: Amit Langote Cc: Jesper Pedersen , Thomas Munro , Robert Haas , Jeevan Ladhe , Pg Hackers Subject: Re: partition tree inspection functions Message-ID: <20181010040150.GD2204@paquier.xyz> References: <20181005065219.GD14664@paquier.xyz> <5aa10b81-1d56-2983-9c2b-bc2164f6a803@redhat.com> <20181006062631.GB4835@paquier.xyz> <1696808d-fa0d-2e8b-bc20-722616758353@lab.ntt.co.jp> <20181009091000.GA1582@paquier.xyz> <20181009100544.GB1582@paquier.xyz> <20181009111720.GC1582@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Qz2CZ664xQdCRdPu" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Qz2CZ664xQdCRdPu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 10, 2018 at 11:54:48AM +0900, Amit Langote wrote: > I was partly wrong in saying that we wouldn't need any changes to support > partitioned indexes here. Actually, the core function > find_inheritance_children wouldn't scan pg_inherits for us if we pass an > (partitioned) index to it, even if the index may have children. > > It appears that we don't set relhassubclass for partitioned indexes (that > is, on parent indexes), so the above the test is useless for indexes. Aha, so that was it. > Maybe, we need to start another thread to discuss whether we should be > manipulating relhassubclass for index partitioning (I'd brought this up in > the context of relispartition, btw [1]). I'm not immediately sure if > setting relhassubclass correctly for indexes will have applications beyond > this one, but it might be something we should let others know so that we > can hear more opinions. This reminds of https://postgr.es/m/20180226053613.GD6927@paquier.xyz, which has resulted in relhaspkey being removed from pg_class with f66e8bf8. I would much prefer if we actually removed it... Now relhassubclass is more tricky than relhaspkey as it gets used as a fast-exit path for a couple of things: 1) prepunion.c when planning for child relations. 2) plancat.c 2) analyze.c 3) rewriteHandler.c > For time being, I've modified that code as follows: >=20 > @@ -68,9 +70,11 @@ find_inheritance_children(Oid parentrelId, LOCKMODE > lockmode) >=20 > /* > * Can skip the scan if pg_class shows the relation has never had a > - * subclass. > + * subclass. Since partitioned indexes never have their > + * relhassubclass set, we cannot skip the scan based on that. > */ > - if (!has_subclass(parentrelId)) > + if (get_rel_relkind(parentrelId) !=3D RELKIND_PARTITIONED_INDEX && > + !has_subclass(parentrelId)) > return NIL; I don't like living with this hack. What if we simply nuked this fast-path exit all together? The only code path where this could represent a performance issue is RelationBuildPartitionKey(), but we expect a partitioned table to have children anyway, and there will be few cases where partitioned tables have no partitions. -- Michael --Qz2CZ664xQdCRdPu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlu9ea4ACgkQnvQgOdby QH1O+A/+LvAgmQiJXSk8CbgoWoMbnWVrz/pq3ma26FaQ0tvB0g1KE9/d8fmEj+wp qkOv+GQvpVVd1gJ/2B3XffJFMS0bVCqA2Hp+Eu+1k4rp2uujYgMTtY9U2sT1VuNT YNsNEKtPXHVte/ShZsIcJ0fCC04kEwy4f5aw181PMPK72apIsmMoOVEJFgn4pna2 8Je/3G38gjyCXU4iU3iHTnhsqRjalAKSVk2USksh1PgePw35J0lkfKigH4aPZ0iP Wei3TOiBy3NGcWdjo6YSyxDyVQ2Zk2lEggUvchOM6jgv8/4kLcZL0zNSU0M80xRY DkL9IgGLA3PxT2B/9wkPl9WNbLr/QQhamX1nVodq+i2qJkHezIeXR3PSWQhw9TqO x9PvB+2y8TdXDTKdD3j89pegSX764Jv1JikkMEB21rI7b1crpxikVL6s8BAsG4FT jA5ywdt3ARL0B7ko1Sl6g+9UQR0WYGuY6HoIkSxfI0KgagIETOAD3xyoEshIsP16 fr060IGtsTEQ85tbUdXZkVVYRgQ4iXsgfZDQ6RW0wmiDCQoVMWiJFgXCPeu6gdCe x7g7cns7zO2nSCey7UAYO60hxS00C1fn9OOv4uRuRtWG62H1oT0pA6g34SFghxNL 9xr1AqNBy6aKrgdln3SHLGIRPwnOczExy6lezLR6kuI74H2ewMc= =Ys4K -----END PGP SIGNATURE----- --Qz2CZ664xQdCRdPu--