Skip to content

Faster execution of indexed STARTING WITH with UNICODE collation #6872

Description

@asfernandes

Initial execution time of indexed STARTING WITH lookup with UNICODE collation is very slow.

Test cases with timings using the debug build:

-- UTF8 without collation

recreate table t1 (c1 varchar(10) character set utf8)!
create index t1_idx on t1 (c1)!

execute block
as
    declare n integer = 0;
    declare v type of column t1.c1;
begin
    while (n < 100000)
    do
    begin
        select 1 from t1 where c1 starting with 'x' into v;
        n = n + 1;
    end
end!

-- Elapsed time = 0.422 sec
-- WIN1252 collation WIN_PTBR

recreate table t1 (c1 varchar(10) character set win1252 collate win_ptbr)!
create index t1_idx on t1 (c1)!

execute block
as
    declare n integer = 0;
    declare v type of column t1.c1;
begin
    while (n < 100000)
    do
    begin
        select 1 from t1 where c1 starting with 'x' into v;
        n = n + 1;
    end
end!

-- Elapsed time = 0.440 sec
-- UTF8 collation UNICODE

recreate table t1 (c1 varchar(10) character set utf8 collate unicode)!
create index t1_idx on t1 (c1)!

execute block
as
    declare n integer = 0;
    declare v type of column t1.c1;
begin
    while (n < 100000)
    do
    begin
        select 1 from t1 where c1 starting with 'x' into v;
        n = n + 1;
    end
end!

-- Elapsed time = 6.498 sec

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions