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 1fqB5t-00046p-AA for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Aug 2018 05:45:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fqB5o-0007ZK-EC for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Aug 2018 05:45: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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqB5o-0007ZC-5b for pgsql-hackers@lists.postgresql.org; Thu, 16 Aug 2018 05:45:08 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fqB5k-00071I-N7 for pgsql-hackers@postgresql.org; Thu, 16 Aug 2018 05:45:07 +0000 Received: by mail-pf1-x441.google.com with SMTP id p12-v6so1512952pfh.2 for ; Wed, 15 Aug 2018 22:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4G7IT9Dn8An1v2H/NKx2+uUvVBNRkZECLqtuQPWCDag=; b=d/hbyXfLMY88Ndzb1whdxj1Lpo5JgV47vBg8+W1S3mfN5o63e5dh0yBBVSsC5r4ABQ S0FCEFGZi0WWylluawHezoFsyOYpsu6lxt+figdSr++LTiXj12iRnPtzs6e/4gvQ+U7E s1R7pP8AKrcBCfLz57iWHT6zW0wAml4w3vOgMXJo6XWX3Sq0EE5xHTtOue4eqDH62j8h +zxRma2UCtkJuKzPIrZF6Yxl+QiamMtDl4FiLYFGK8bholBeKbdIObGkhMsUqI466gd1 /ugwq+H1AYveH47ncWF856geTfoRb92GAqaTctjETs0y7MivR6gbdsbi5aDeGvDl85SO d9vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=4G7IT9Dn8An1v2H/NKx2+uUvVBNRkZECLqtuQPWCDag=; b=oSrgxdQQGQBvmXteZP1AqrH/ZanO4a4xA2WYbB4KmeqFM4nij2fR6jStvMeTt0PYb+ OyVg/z6+yz6jdMLeyiXokg5i/OLYPiQfGZyjguk/3jXP3Amz7WieFbZa4oL1atuaowu7 lqM7YVWjp4AaIfCxLrhNCnAk6xIn80uZQHiaRlw7O2mTuEf+jGBPEGWtFEvLRyAel4kW Ov9p/OzwyfaHyEfmBqqaG+WQhG5orhXBiR0Yt1YHqdX75/qvbmuf7vn4GTFtWpVAEQnw rtOA4shQzep5D8hMIrGLspqwRmwpi/Uj6ihIib3pDxvTtQOuN51Nbl6R14lI/Vhkxtxq K+Pw== X-Gm-Message-State: AOUpUlHprAVhl3Pn6g6K+QkgEmKgy19khDXIXugkp2syIHc3zpaoKl2Y 07WXdiUxKMvXp/kuW7YrewY= X-Google-Smtp-Source: AA+uWPxjKu/oxvmhY8lf+lyghr7fHT0UppkYnFHO81G1EVVOajpKSgXuiRbVzv9Ge2Ew5wDW/PzJ4w== X-Received: by 2002:a65:5c4b:: with SMTP id v11-v6mr27999401pgr.445.1534398302237; Wed, 15 Aug 2018 22:45:02 -0700 (PDT) Received: from [192.168.1.12] (c-67-160-197-49.hsd1.ca.comcast.net. [67.160.197.49]) by smtp.gmail.com with ESMTPSA id v8-v6sm29265395pff.120.2018.08.15.22.45.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Aug 2018 22:45:01 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Index Skip Scan From: Bhushan Uparkar In-Reply-To: Date: Wed, 15 Aug 2018 22:44:58 -0700 Cc: pgsql-hackers , Andrew Dunstan , Alexander Korotkov Content-Transfer-Encoding: quoted-printable Message-Id: <89F84E17-D684-4717-B66F-0F05CB00168E@gmail.com> References: <707b6f68-16fa-7aa7-96e5-eeb4865e6a30@redhat.com> To: Jesper Pedersen X-Mailer: Apple Mail (2.3273) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello Jesper, I was reviewing index-skip patch example and have a comment on it. = Example query =E2=80=9Cselect distinct b from t1=E2=80=9D is equivalent = to =E2=80=9Cselect b from t1 group by b=E2=80=9D. When I tried the 2nd = form of query it came up with different plan, is it possible that index = skip scan can address it as well?=20 postgres=3D# explain verbose select b from t1 group by b; QUERY PLAN = --------------------------------------------------------------------------= -------------------------- Group (cost=3D97331.29..97332.01 rows=3D3 width=3D4) Output: b Group Key: t1.b -> Gather Merge (cost=3D97331.29..97331.99 rows=3D6 width=3D4) Output: b Workers Planned: 2 -> Sort (cost=3D96331.27..96331.27 rows=3D3 width=3D4) Output: b Sort Key: t1.b -> Partial HashAggregate (cost=3D96331.21..96331.24 = rows=3D3 width=3D4) Output: b Group Key: t1.b -> Parallel Seq Scan on public.t1 = (cost=3D0.00..85914.57 rows=3D4166657 width=3D4) Output: a, b (14 rows) Time: 1.167 ms =E2=80=94 And here is the original example postgres=3D# explain verbose SELECT DISTINCT b FROM t1; QUERY PLAN = --------------------------------------------------------------------------= ----- Index Skip Scan using idx_t1_b on public.t1 (cost=3D0.43..1.30 rows=3D3 = width=3D4) Output: b (2 rows) Time: 0.987 ms > On Jun 18, 2018, at 10:31 AM, Alexander Korotkov = wrote: >=20 > Hi! >=20 > On Mon, Jun 18, 2018 at 6:26 PM Jesper Pedersen > wrote: >> I would like to start a discussion on Index Skip Scan referred to as >> Loose Index Scan in the wiki [1]. >=20 > Great, I glad to see you working in this! >=20 >> However, as Robert Haas noted in the thread there are issues with the >> patch as is, especially in relationship to the amcanbackward = functionality. >>=20 >> A couple of questions to begin with. >>=20 >> Should the patch continue to "piggy-back" on T_IndexOnlyScan, or = should >> a new node (T_IndexSkipScan) be created ? If latter, then there = likely >> will be functionality that needs to be refactored into shared code >> between the nodes. >=20 > Is skip scan only possible for index-only scan? I guess, that no. We > could also make plain index scan to behave like a skip scan. And it > should be useful for accelerating DISTINCT ON clause. Thus, we might > have 4 kinds of index scan: IndexScan, IndexOnlyScan, IndexSkipScan, > IndexOnlySkipScan. So, I don't think I like index scan nodes to > multiply this way, and it would be probably better to keep number > nodes smaller. But I don't insist on that, and I would like to hear > other opinions too. >=20 >> Which is the best way to deal with the amcanbackward functionality ? = Do >> people see another alternative to Robert's idea of adding a flag to = the >> scan. >=20 > Supporting amcanbackward seems to be basically possible, but rather > complicated and not very efficient. So, it seems to not worth > implementing, at least in the initial version. And then the question > should how index access method report that it supports both skip scan > and backward scan, but not both together? What about turning > amcanbackward into a function which takes (bool skipscan) argument? > Therefore, this function will return whether backward scan is > supported depending of whether skip scan is used. >=20 >> I wasn't planning on making this a patch submission for the July >> CommitFest due to the reasons mentioned above, but can do so if = people >> thinks it is best. The patch is based on master/4c8156. >=20 > Please, register it on commitfest. If even there wouldn't be enough > of time for this patch on July commitfest, it's no problem to move it. >=20 > ------ > Alexander Korotkov > Postgres Professional: http://www.postgrespro.com > The Russian Postgres Company >=20 >=20