提高SQLite查询性能
我已经在SQLite和SQLServer中运行了以下查询。在SQLite上,查询从未完成运行——我让它坐了几个小时,仍然继续运行。在SQLServer上,运行只需不到一分钟。这个表有几十万条记录。有没有办法提高SQLite中查询的性能提高SQLite查询性能,sqlite,Sqlite,我已经在SQLite和SQLServer中运行了以下查询。在SQLite上,查询从未完成运行——我让它坐了几个小时,仍然继续运行。在SQLServer上,运行只需不到一分钟。这个表有几十万条记录。有没有办法提高SQLite中查询的性能 update tmp_tbl set prior_symbol = (select o.symbol from options o where o.underl
update tmp_tbl
set prior_symbol = (select o.symbol
from options o
where o.underlying_ticker = tmp_tbl.underlying_ticker
and o.option_type = tmp_tbl.option_type
and o.expiration = tmp_tbl.expiration
and o.strike = (select max(o2.strike)
from options o2
where o2.underlying_ticker = tmp_tbl.underlying_ticker
and o2.option_type = tmp_tbl.option_type
and o2.expiration = tmp_tbl.expiration
and o2.strike < tmp_tbl.strike));
以及:
但那没用。查询仍在继续计时,没有任何输出——我让它运行了近40分钟
tmp_tbl的表格定义为:
创建表tmp_tblid整数主键,
符号文本,
基本股票代码文本,
选项_类型文本,
实打实,,
过期文本,
中雷亚尔,
之前的符号是真实的,
Previor_premium real,
实际比率,
错误标志位;您是否为where字段定义了索引?是的,请向我们展示更多的架构表和索引,以便我们了解情况。还有,什么解释查询计划把查询放在这里输出?热舔,我在创建索引后运行查询,但查询的性能仍然不是我所期望的。考虑到表中只有370k条记录,我希望这个查询相当快,最多几秒钟。卡梅隆-我不知道你指的是什么。这是我第一次发布问题,所以很可能是我错误地包含了一些内容。
create index options_table_index on options(underlying_ticker, option_type, expiration, strike);
create index tmp_tbl_index on tmp_tbl(underlying_ticker, option_type, expiration, strike);