Indexing 具有LIKE的子字符串搜索是否受益于索引?

Indexing 具有LIKE的子字符串搜索是否受益于索引?,indexing,sql-like,hsqldb,Indexing,Sql Like,Hsqldb,假设HSQLDB中有以下表格定义: create table message(id varchar(255) primary key not null, data clob not null); HSQLDB在id(主键)上自动创建的索引是否会加速子字符串搜索,如下所示 select * from message where id like 'foo:%' 显然,子字符串搜索确实受益于该列上的索引 运行 explain plan for select * from message where

假设HSQLDB中有以下表格定义:

create table message(id varchar(255) primary key not null, data clob not null);
HSQLDB在
id
(主键)上自动创建的索引是否会加速子字符串搜索,如下所示

select * from message where id like 'foo:%'

显然,子字符串搜索确实受益于该列上的索引

运行

explain plan for select * from message where id like 'foo:%'
给我

…
access=INDEX PRED
…
就像简单的等号比较一样。这似乎适用于任何子字符串,例如
“%foo%”
,而不仅仅是字符串的开头

为了进行比较,如果我在
数据
列(该列没有索引,因此需要完整的表扫描)上尝试相同的操作,我会得到

…
access=FULL SCAN
…