You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
B-Tree indices support incremental sorts on top of an index.
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=# explain select 1 from temp_table order by v;
QUERY PLAN
-----------------------------------------------------------------------------------------
Index Only Scan using temp_table_v_idx on temp_table (cost=0.13..12.18 rows=3 width=8)
(1 row)
postgres=# explain select 1 from temp_table order by v, id;
QUERY PLAN
-------------------------------------------------------------------------------------------
Incremental Sort (cost=4.15..12.31 rows=3 width=12)
Sort Key: v, id
Presorted Key: v
-> Index Scan using temp_table_v_idx on temp_table (cost=0.13..12.18 rows=3 width=12)
(4 rows)
postgres=# explain select 1 from temp_table order by v, b;
QUERY PLAN
-------------------------------------------------------------------------------------------
Incremental Sort (cost=4.15..12.31 rows=3 width=12)
Sort Key: v, b
Presorted Key: v
-> Index Scan using temp_table_v_idx on temp_table (cost=0.13..12.18 rows=3 width=12)
(4 rows)
We should do the same.
The text was updated successfully, but these errors were encountered:
B-Tree indices support incremental sorts on top of an index.
We should do the same.
The text was updated successfully, but these errors were encountered: