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 1gaO7Y-0001Ik-Kt for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Dec 2018 16:57:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gaO7V-0001GQ-If for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Dec 2018 16:57:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gaO7V-0001Et-6P for pgsql-hackers@lists.postgresql.org; Fri, 21 Dec 2018 16:57:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gaO7S-0001Vs-Mp for pgsql-hackers@lists.postgresql.org; Fri, 21 Dec 2018 16:57:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wBLGvmDX028823; Fri, 21 Dec 2018 11:57:48 -0500 From: Tom Lane To: Edmund Horner cc: David Rowley , Tomas Vondra , PostgreSQL Developers Subject: Re: Tid scan improvements In-reply-to: References: <8469.15453! 44467@sss.pgh.pa.us> <20220.1545363076@sss.pgh.pa.us> Comments: In-reply-to Edmund Horner message dated "Fri, 21 Dec 2018 21:04:58 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28821.1545411468.1@sss.pgh.pa.us> Date: Fri, 21 Dec 2018 11:57:48 -0500 Message-ID: <28822.1545411468@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Edmund Horner writes: > Ok. I think that will simplify things. So if I follow you correctly, > we should do: > 1. If has_useful_pathkeys is true: generate pathkeys (for CTID ASC), > and use truncate_useless_pathkeys on them. > 2. If we have tid quals or pathkeys, emit a TID scan path. Check. > For the (optional) backwards scan support patch, should we separately > emit another path, in the reverse direction? What indxpath.c does is, if has_useful_pathkeys is true, to generate pathkeys both ways and then build paths if the pathkeys get past truncate_useless_pathkeys. That seems sufficient in this case too. There are various heuristics about whether it's really useful to consider both sort directions, but that intelligence is already built into truncate_useless_pathkeys. tid quals with no pathkeys would be reason to generate a forward path, but not reason to generate a reverse path, because then that would be duplicative. regards, tom lane