Sqlite DB查询需要很长时间的WP8 [英] Sqlite DB querying takes a long time WP8

查看:151
本文介绍了Sqlite DB查询需要很长时间的WP8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此链接作为参考,使用sqlite.net构建Windows Phone 8应用程序: -



http://developer.nokia.com/community/wiki/How_to_use_SQLite_in_Windows_Phone



是项目中正在接种在隔离存储中的数据库。



我试图在MainPage.xaml.cs中连接到该数据库,如下所示: -

  protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
using(SQLiteConnection db = new SQLiteConnection(App._dbPath))
{
db.GetTableInfo(IWMCemeteries);
try
{
List< IWMCemeteries> cemeteriesList = db.Table< IWMCemeteries>()。ToList< IWMCemeteries>();
MessageBox.Show(表中的元素数量为+ cemeteriesList.Count);
}
catch(Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}

问题是



我尝试了一个运行原始查询的备用方法,如下所示: -

 列表< IWMCemeteries> cemeteries = db.Query< IWMCemeteries>(select * from IWMCemeteries); 
MessageBox.Show(list of elements in list is+ cemeteries.Count);

但这似乎需要更长时间

有人可以告诉我我在这里做错了什么吗?



谢谢,



Rajeev

解决方案

这里没有什么不对的地方。有些人注意到,有26k行,你开始使用一个有趣的大量数据。因此,在使用lite数据库的移动设备中,您必须根据实际需要调整您的请求:




  • 然后使用SELECT COUNT(*)

  • 您要显示列表中的所有行,然后使用分页或异步加载(向下滚动)每次只提取20个元素



在任何应用程式中,但主要是在行动装置上,您必须考虑移动的资料量。



这样,任何请求都将是即时的,您的应用程序将执行良好。


I am building a Windows Phone 8 app using sqlite.net using this link as a reference:-

http://developer.nokia.com/community/wiki/How_to_use_SQLite_in_Windows_Phone

There is a database in the project which is being seeded in the Isolated Storage. The database contains only one table which has almost 26k entries.

I am trying to connect to that database in my MainPage.xaml.cs as follows:-

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);
    using (SQLiteConnection db = new SQLiteConnection(App._dbPath))
    {
        db.GetTableInfo("IWMCemeteries");
        try
        {
            List<IWMCemeteries> cemeteriesList = db.Table<IWMCemeteries>().ToList<IWMCemeteries>();
             MessageBox.Show("Number of elements in table is " + cemeteriesList.Count);
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex.Message);
        }
    }
}

The problem is that it takes too long(over 25 seconds) for the message dialog to show up.

I tried an alternate method running a raw query as follows:-

List<IWMCemeteries> cemeteries = db.Query<IWMCemeteries>("select * from IWMCemeteries");
MessageBox.Show("Number of elements in list is " + cemeteries.Count);

But this seems to take even longer!(almost 30s).

Can someone please tell me what I am doing wrong here?

Thanks,

Rajeev

解决方案

Nothing wrong here for me. As some people noticed, with 26k rows you are starting to work with an interesting bulk of data. So, in mobile devices working with a "lite" database, you must adapt your request depending on what you really need :

  • You want the number of rows, then use SELECT COUNT(*)
  • You want to display all rows in a list, then use paging or asynchronous loading (on scroll down) to fetch only 20 elements each times.

In any apps, but mostly in mobile devices, you have to consider the volume of data which moves.

In this way, any request would be instant and your application will perform well.

这篇关于Sqlite DB查询需要很长时间的WP8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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