ORMLite在Android上表现不佳? [英] ORMLite poor performance on Android?

查看:122
本文介绍了ORMLite在Android上表现不佳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Android开发应用程序,并尝试使用ORMLite,但性能似乎是真正的穷人。任何人都经历呢?

I'm developing an application for Android, and have tried to use ORMLite, but the performance seems to be really poor. Has anyone else experienced this?

还是我做错了什么?

修改

没有,我没有做任何连接,所有的查询均采用索引键作为参数。但数据集是resonably大,且有相当多comparisions

No I'm not doing any joins, and all queries are made with indexed keys as parameters. But the data set is resonably big, and there is quite many comparisions.

没有尝试过做纯粹的SQLite ...

Haven't tried to do with pure SQLite...

推荐答案

我想最好的答案是,表现 ORMLite 很大程度上取决于你如何使用它。如果你可以张贴一些code样品,以及一些业绩数字,我们也许能够帮助更具体。

I guess the best answer is that the performance of ORMLite is highly dependent on how you use it. If you could post some of the code samples as well as some of the performance numbers, we may be able to help more specifically.

如果你正在做一些数据库操作一次,你应该考虑使用<一个href="http://ormlite.com/javadoc/ormlite-core/com/j256/ormlite/dao/Dao.html#callBatchTasks%28java.util.concurrent.Callable%29"相对=nofollow> Dao.callBatchTasks() 方法。在Android上,它启动一个数据库事务,调用传递可赎回并返回后,将提交该事务。这是显著更快,如果你有,例如,插入的行数到表

If you are making a number of database operations at one time, you should consider using the Dao.callBatchTasks() method. Under Android, it starts a database transaction, calls the passed in Callable and after it returns, it commits the transaction. This is significantly faster if you are, for example, inserting a number of rows into the table.

另请参阅:为什么DAO方法这么慢ORMLite?

修改

如果您的查询采取了一会儿,然后最有可能的时间被消耗在SQLite的。您可以尝试减少一些数据集或调整比较的次数,看看东西跑得更快,所以你可以明确确定的SQLite(和更多可能只是IO)的罪魁祸首。

If your queries are taking a while then most likely the time is being spent in SQLite. You could try reducing some of the dataset or tuning the number of comparisons to see if things run faster so you can definitively determine that SQLite (and more likely just IO) is the culprit.

这篇关于ORMLite在Android上表现不佳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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