关联查询时,涉及关联的字段,可以创建索引,大幅度提高查询效率。
语法:
-- 创建无索引的表格
create table testNoPK (
id int not null,
name varchar(10)
);
-- 创建普通索引
create index IDX_testNoPK_Name on testNoPK (name);
示例,如:
create index IDX_t_search_history_queryId on t_search_history (queryId);