我有一个具有唯一约束的表
create table if not exists watchlist(
_id integer primary key autoincrement,
country text not null,
name text not null,
unique (country, name) on conflict replace
);
由于我的查询大部分时间都会在WHERE子句中涉及country
和name
。为了加快查询速度,我想知道我还需要创建
create index idx_country_name on watchlist(country, name);
答案 0 :(得分:1)
您的唯一约束将创建一个隐式索引,该索引将由sqlite自动创建。因此,无需在这些列上创建唯一索引。