SQLite的:.NET比本地慢得多? [英] SQLite: .Net much slower than native?

查看:207
本文介绍了SQLite的:.NET比本地慢得多?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的查询:

  SELECT * FROM [GeoName] 
WHERE((-26.3665122100029-LAT) *( - 26.3665122100029-LAT))+((27.5978928658078龙)*(27.5978928658078龙))< 0.005
ORDER BY((-26.3665122100029-LAT)*( - 26.3665122100029-LAT))+((27.5978928658078龙)*(27.5978928658078龙))
边界20

这将返回20最近点。



在本地的SQLite运行此返回在78ms造成的,但是从净sqlite的环境中不占1400ms。



有什么建议?



我有我的ORM结构中,并使用参数值此查询。 。曾经也尝试过作为原生文本查询



运行查询(内我的ORM层)的代码:

 私有静态的IDataReader CallSqlReader(字符串的SQLStatement,字典<字符串对象>参数)
{
ConnectionCheck();


{
VAR CMD = conn.CreateCommand();
cmd.CommandText =的SQLStatement;
cmd.CommandType = CommandType.Text;
的foreach(在参数VAR项)
{
cmd.Parameters.AddWithValue(item.Key,item.Value);
}
返回cmd.ExecuteReader();
}
赶上{}
返回NULL;
}


解决方案

据预计,非访问数据库的手段-native会慢一些,也许更慢,比访问同一个数据库的本地的方法。别急,看看是否有人显示出来谁拥有了在此之前的问题,并已经能够拿出某种形式的解决之道。在此同时,如果你告诉你究竟是如何从DOTNET中执行此查询它可能会有所帮助。


Here is my query:

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

This returns the 20 closest points.

Running this in native sqlite returns a result within 78ms, but from within the .Net sqlite environment it takes nearly 1400ms.

Any suggestions?

I have this query within my ORM structure and using parameterized values. Have also tried it as a native text query.

The code that runs the query (inside my ORM layers):

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;
}

解决方案

It is expected that a non-native means of accessing a database will be slower, perhaps much slower, than the native means of accessing same database. But wait to see if someone shows up who has had this problem before and has been able to come up with some kind of solution to it. In the mean time, it will probably help if you show exactly how you execute this query from within dotnet.

这篇关于SQLite的:.NET比本地慢得多?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆