这是我的查询:
SELECT * FROM [GeoName]
WHERE ((-26.3665122100029-Lat)*(-26.3665122100029-Lat))+((27.5978928658078-Long)*(27.5978928658078-Long)) < 0.005
ORDER BY ((-26.3665122100029-Lat)*(-26.3665122100029-Lat))+((27.5978928658078-Long)*(27.5978928658078-Long))
LIMIT 20
这将返回 20 个最近的点。
在本机 sqlite 中运行它会在 78 毫秒内返回结果,但在 .Net sqlite 环境中则需要将近 1400 毫秒。
有什么建议么?
我在我的 ORM 结构中有这个查询并使用参数化值。还尝试将其作为本机文本查询。
运行查询的代码(在我的 ORM 层内):
private static IDataReader CallSqlReader(string SqlStatement, Dictionary<string, object> parameters)
{
ConnectionCheck();
try
{
var cmd = conn.CreateCommand();
cmd.CommandText = SqlStatement;
cmd.CommandType = CommandType.Text;
foreach (var item in parameters)
{
cmd.Parameters.AddWithValue(item.Key, item.Value);
}
return cmd.ExecuteReader();
}
catch { }
return null;
}