Skip to content

support WHERE predicate in indexes#2743

Draft
jennifersp wants to merge 2 commits into
mainfrom
jennifer/index-where
Draft

support WHERE predicate in indexes#2743
jennifersp wants to merge 2 commits into
mainfrom
jennifer/index-where

Conversation

@jennifersp
Copy link
Copy Markdown
Contributor

No description provided.

@jennifersp jennifersp requested a review from Hydrocharged May 20, 2026 23:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

Main PR
covering_index_scan_postgres 1307.30/s 1315.24/s +0.6%
index_join_postgres 195.75/s 197.71/s +1.0%
index_join_scan_postgres 207.10/s 206.79/s -0.2%
index_scan_postgres 12.31/s 12.32/s 0.0%
oltp_point_select 2280.51/s 2308.49/s +1.2%
oltp_read_only 1839.63/s 1833.82/s -0.4%
select_random_points 130.55/s 131.38/s +0.6%
select_random_ranges 867.38/s 870.51/s +0.3%
table_scan_postgres 11.87/s 12.09/s +1.8%
types_table_scan_postgres 5.46/s 5.58/s +2.1%

Copy link
Copy Markdown
Collaborator

@Hydrocharged Hydrocharged left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread testing/go/index_test.go
Comment on lines +1414 to +1421
// TODO: is it correct way to display index predicate?
Query: "EXPLAIN SELECT * FROM t WHERE a > 0;",
Expected: []sql.Row{
{"IndexedTableAccess(t)"},
{" ├─ index: [t.a,t.a > 1]"},
{" ├─ filters: [{(0, ∞)}]"},
{" └─ columns: [a b]"},
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the correct way. The output seems wrong, in that the partial index doesn't seem like it's actually relevant here since we're starting from a == 0 which is outside the range. I'd assume that analysis properly skips the index, but displays it here for some reason.

@github-actions
Copy link
Copy Markdown
Contributor

Main PR
Total 42090 42090
Successful 18126 18171
Failures 23964 23919
Partial Successes1 5384 5363
Main PR
Successful 43.0649% 43.1718%
Failures 56.9351% 56.8282%

${\color{lightgreen}Progressions (62)}$

aggregates

QUERY: create index minmaxtest3i on minmaxtest3(f1) where f1 is not null;

alter_table

QUERY: alter table attbl replica identity using index pk_attbl;

constraints

QUERY: UPDATE unique_tbl SET i = i+1;
QUERY: SELECT * FROM unique_tbl;
QUERY: INSERT INTO unique_tbl VALUES (3, 'three');
QUERY: SELECT * FROM unique_tbl;
QUERY: INSERT INTO unique_tbl VALUES (1, 'five');
QUERY: SELECT * FROM unique_tbl;
QUERY: INSERT INTO unique_tbl VALUES(3, 'tree');

create_index

QUERY: SELECT pg_get_indexdef('unique_idx3'::regclass);
QUERY: ALTER TABLE concur_replident REPLICA IDENTITY
  USING INDEX concur_replident_i_idx;

create_table

QUERY: create index part_column_drop_b_pred on part_column_drop(b) where b = 1;
QUERY: create index part_column_drop_d_pred on part_column_drop(d) where d = 2;

create_table_like

QUERY: CREATE UNIQUE INDEX inhz_xx_idx on inhz (xx) WHERE xx <> 'test';

generated

QUERY: CREATE INDEX gtest22c_pred_idx ON gtest22c (a) WHERE b > 0;

indexing

QUERY: create index on idxpart1 (a) where b > 1;
QUERY: create index on idxpart2 (a) where b > 1000;
QUERY: create index on idxpart (a) where b > 1000;
QUERY: alter table only parted_replica_tab_1 replica identity
  using index parted_replica_idx_1;
QUERY: alter table only parted_replica_tab_1 replica identity
  using index parted_replica_idx_1;

insert_conflict

QUERY: create unique index part_comp_key_index on insertconflicttest(key, fruit) where key < 5;
QUERY: create unique index partial_key_index on insertconflicttest(key) where fruit like '%berry';
QUERY: create unique index insertconflicti2 on insertconflict(b)
  where coalesce(a, 1) > 0;

join

QUERY: create index j1_id1_idx on j1 (id1) where id1 % 1000 = 1;
QUERY: create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1;

publication

QUERY: ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY FULL;
QUERY: ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY FULL;
QUERY: ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY NOTHING;
QUERY: ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY NOTHING;
QUERY: ALTER TABLE rf_tbl_abcd_pk REPLICA IDENTITY USING INDEX idx_abcd_pk_c;
QUERY: ALTER TABLE rf_tbl_abcd_nopk REPLICA IDENTITY USING INDEX idx_abcd_nopk_c;
QUERY: ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key;
QUERY: ALTER TABLE testpub_tbl5 REPLICA IDENTITY USING INDEX testpub_tbl5_b_key;
QUERY: ALTER TABLE testpub_tbl6 REPLICA IDENTITY FULL;
QUERY: ALTER TABLE testpub_tbl8_0 REPLICA IDENTITY USING INDEX testpub_tbl8_0_pkey;
QUERY: ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey;
QUERY: ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL;
QUERY: ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey;
QUERY: ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY FULL;
QUERY: ALTER TABLE testpub_tbl8_1 REPLICA IDENTITY USING INDEX testpub_tbl8_1_pkey;

Footnotes

  1. These are tests that we're marking as Successful, however they do not match the expected output in some way. This is due to small differences, such as different wording on the error messages, or the column names being incorrect while the data itself is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants