Skip to content

Optimize creation of expression and partial indices#7559

Merged
dyemanov merged 5 commits intomasterfrom
v5-cond-expr-idx-speedup
May 9, 2023
Merged

Optimize creation of expression and partial indices#7559
dyemanov merged 5 commits intomasterfrom
v5-cond-expr-idx-speedup

Conversation

@dyemanov
Copy link
Copy Markdown
Member

@dyemanov dyemanov commented Apr 28, 2023

The idea is to share an expression/condition request between multiple processed records in cases when it's possible (index creation, garbage collection, validation).

Test case:

recreate table t (id int) ;
insert into t select row_number() over() from rdb$types, rdb$types, rdb$types;
commit;

set stat on;

create index it0 on t (id);
create index it1 on t (id) where id is not null;
create index it2 on t computed (id+0);
create index it3 on t computed (id+0) where id is not null;

-- v5

SQL> create index it0 on t (id);
Elapsed time = 9.331 sec

SQL> create index it1 on t (id) where id is not null;
Elapsed time = 69.126 sec

SQL> create index it2 on t computed (id+0);
Elapsed time = 72.234 sec

SQL> create index it3 on t computed (id+0) where id is not null;
Elapsed time = 129.571 sec

-- v5 with patch

SQL> create index it0 on t (id);
Elapsed time = 9.369 sec

SQL> create index it1 on t (id) where id is not null;
Elapsed time = 10.920 sec

SQL> create index it2 on t computed (id+0);
Elapsed time = 12.464 sec

SQL> create index it3 on t computed (id+0) where id is not null;
Elapsed time = 14.466 sec

Copy link
Copy Markdown
Member

@hvlad hvlad left a comment

Choose a reason for hiding this comment

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

Before optimization, condition\expression's request was unwound for every record processed, now it is done after processing of a many records, is it safe ?
Note, condition\expression could be complex and contain cursors, for example.

Comment thread src/jrd/btr.cpp Outdated
Comment thread src/jrd/btr.cpp
Comment thread src/jrd/btr.cpp
Comment thread src/jrd/btr.h Outdated
Comment thread src/jrd/btr.h Outdated
Comment thread src/jrd/idx.cpp
@dyemanov dyemanov merged commit f581f37 into master May 9, 2023
@dyemanov dyemanov deleted the v5-cond-expr-idx-speedup branch May 12, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants