Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nested loop within index scan #85

Open
dqii opened this issue Aug 25, 2023 · 0 comments
Open

Support nested loop within index scan #85

dqii opened this issue Aug 25, 2023 · 0 comments
Labels
core Core Database

Comments

@dqii
Copy link
Contributor

dqii commented Aug 25, 2023

B tree indices support nested loops within index scans.

postgres=# create table temp_table(id serial primary key, v integer, b integer);
CREATE TABLE
postgres=# insert into temp_table(v) values (1), (2), (3);
INSERT 0 3
postgres=# create index on temp_table(v);
CREATE INDEX
postgres=# set enable_seqscan = off;
SET
postgres=# create table temp_table2(id serial primary key);
CREATE TABLE
postgres=# explain select 1 from temp_table join temp_table2 using (id) order by v;
                                          QUERY PLAN                                           
-----------------------------------------------------------------------------------------------
 Nested Loop  (cost=0.29..28.70 rows=3 width=8)
   ->  Index Scan using temp_table_v_idx on temp_table  (cost=0.13..12.18 rows=3 width=8)
   ->  Index Only Scan using temp_table2_pkey on temp_table2  (cost=0.15..5.51 rows=1 width=4)
         Index Cond: (id = temp_table.id)

We should do the same.

@Ngalstyan4 Ngalstyan4 added the core Core Database label Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core Database
Projects
None yet
Development

No branches or pull requests

2 participants