Index Skip Scan
От | Jesper Pedersen |
---|---|
Тема | Index Skip Scan |
Дата | |
Msg-id | 707b6f68-16fa-7aa7-96e5-eeb4865e6a30@redhat.com обсуждение исходный текст |
Ответы |
Re: Index Skip Scan
Re: Index Skip Scan |
Список | pgsql-hackers |
Hi all, I would like to start a discussion on Index Skip Scan referred to as Loose Index Scan in the wiki [1]. My use-case is the simplest form of Index Skip Scan (B-Tree only), namely going from CREATE TABLE t1 (a integer PRIMARY KEY, b integer); CREATE INDEX idx_t1_b ON t1 (b); INSERT INTO t1 (SELECT i, i % 3 FROM generate_series(1, 10000000) as i); ANALYZE; EXPLAIN (ANALYZE, VERBOSE, BUFFERS ON) SELECT DISTINCT b FROM t1; HashAggregate (cost=169247.71..169247.74 rows=3 width=4) (actual time=4104.099..4104.099 rows=3 loops=1) Output: b Group Key: t1.b Buffers: shared hit=44248 -> Seq Scan on public.t1 (cost=0.00..144247.77 rows=9999977 width=4) (actual time=0.059..1050.376 rows=10000000 loops=1) Output: a, b Buffers: shared hit=44248 Planning Time: 0.157 ms Execution Time: 4104.155 ms (9 rows) to CREATE TABLE t1 (a integer PRIMARY KEY, b integer); CREATE INDEX idx_t1_b ON t1 (b); INSERT INTO t1 (SELECT i, i % 3 FROM generate_series(1, 10000000) as i); ANALYZE; EXPLAIN (ANALYZE, VERBOSE, BUFFERS ON) SELECT DISTINCT b FROM t1; Index Skip Scan using idx_t1_b on public.t1 (cost=0.43..1.30 rows=3 width=4) (actual time=0.061..0.137 rows=3 loops=1) Output: b Heap Fetches: 3 Buffers: shared hit=13 Planning Time: 0.155 ms Execution Time: 0.170 ms (6 rows) I took Thomas Munro's previous patch [2] on the subject, added a GUC, a test case, documentation hooks, minor code cleanups, and made the patch pass an --enable-cassert make check-world run. So, the overall design is the same. However, as Robert Haas noted in the thread there are issues with the patch as is, especially in relationship to the amcanbackward functionality. A couple of questions to begin with. 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. 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. 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. Any feedback, suggestions, design ideas and help with the patch in general is greatly appreciated. Thanks in advance ! [1] https://wiki.postgresql.org/wiki/Loose_indexscan [2] https://www.postgresql.org/message-id/flat/CADLWmXXbTSBxP-MzJuPAYSsL_2f0iPm5VWPbCvDbVvfX93FKkw%40mail.gmail.com Best regards, Jesper
Вложения
В списке pgsql-hackers по дате отправления: