设备上的 SQL Server CE 性能
我的 SQL Compact 数据库非常简单,只有三个表,其中一个表有一个索引(表有 20 万行;另外两个表各少于一百行)。
我的 Compact Framework 应用程序在目标 Windows Mobile 设备上第一次使用 .sdf 文件时,系统挂起一分多钟,同时对数据库进行“某些操作”:部署时,数据库为 17 MB,部署后第一次使用时,它会膨胀到 24 兆。
所有后续使用都非常快,因此我假设在第一次使用期间正在进行某种初始化/索引构建。我不想让用户受到这种延迟,所以我想知道这个初始化过程是什么以及它是否可以在部署之前执行。
目前,我已将“初始化”数据库复制回桌面以在安装项目中使用,但我真的很想有一个更好的答案/解决方案。我已经在 VS 数据库属性对话框中尝试过“完全压缩/修复”,但这没有什么区别。有什么想法吗?
作为记录,我应该补充一点,数据库仅由设备应用程序读取 - 该代码不会进行任何修改。
My SQL Compact database is very simple, with just three tables and a single index on one of the tables (the table with 200k rows; the other two have less than a hundred each).
The first time the .sdf file is used by my Compact Framework application on the target Windows Mobile device, the system hangs for well over a minute while "something" is done to the database: when deployed, the DB is 17 megabytes, and after this first usage, it balloons to 24 megs.
All subsequent usage is pretty fast, so I'm assuming there's some sort of initialization / index building going on during this first usage. I'd rather not subject the user to this delay, so I'm wondering what this initialization process is and whether it can be performed before deployment.
For now, I've copied the "initialized" database back to my desktop for use in the setup project, but I'd really like to have a better answer / solution. I've tried "full compact / repair" in the VS Database Properties dialog, but this made no difference. Any ideas?
For the record, I should add that the database is only read from by the device application -- no modifications are made by that code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,它会重新创建索引,因为数据库是在台式计算机上创建或打开的。将索引数据库从设备复制到您的设置中。
更多信息在这里:
http://blogs.msdn.com/sqlservercompact/archive/2009/04/01/after-moving-the-database-from-one-platform- to-other-the-first-sqlceconnection-open-takes-more-time.aspx
Yes, it recreates your indexes because the database was created or opened on a desktop computer. Copy your indexed database from the device and into your setup.
more info here:
http://blogs.msdn.com/sqlservercompact/archive/2009/04/01/after-moving-the-database-from-one-platform-to-other-the-first-sqlceconnection-open-takes-more-time.aspx
由于数据库是只读的,并且如果“初始化”数据库不再膨胀,我会简单地将其放入设置中。只是确认您的方法有意义。
Since the db is read only, and if the "initialized" db no longer inflates, I would go with simply putting it into the setup. Just confirming that your approach makes sense.