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

Optimize creation of expression and partial indices #7559

Merged
merged 5 commits into from
May 9, 2023

Conversation

dyemanov
Copy link
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
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.

src/jrd/btr.cpp Outdated Show resolved Hide resolved
src/jrd/btr.cpp Show resolved Hide resolved
src/jrd/btr.cpp Show resolved Hide resolved
src/jrd/btr.h Outdated Show resolved Hide resolved
src/jrd/btr.h Outdated Show resolved Hide resolved
src/jrd/idx.cpp Show resolved Hide resolved
@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