SQLite的插入变慢甚至与交易 [英] SQLite Inserts get slower even with transactions

查看:95
本文介绍了SQLite的插入变慢甚至与交易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有麻烦的SQLite插入性能甚至与交易。 我的Andr​​oid应用程序接收约23.000行从一个Web服务,我不得不将它们插入到一个表。

I'm having troubles with sqlite inserts performance even with transactions. My android app receives approximately 23.000 rows from a web service and I have to insert them into a single table.

Web服务的划分是我收到的每一个请求到WS约2000行,我换一个事务中的2000插件。经过这些刀片做我送了新的要求的WS,并再次使用了新的交易,新2000行。

The web service is partitioned so that I receive about 2000 rows in every request to the WS and I wrap the 2000 inserts within a transaction. After those inserts are done I send the new request to the WS and again use a new transaction for the new 2000 rows.

在开始正常工作。它做了很多每秒的插入。但它变得更慢,终于结束了每秒4或3个刀片,直到它完成了23000行的时间。

At the beginning it works fine. It does a lot of inserts per second. but with the time it gets slower and finally ends up with 4 or 3 inserts per second until it completes the 23000 rows.

是否存在与表的大小有问题吗?当它得到更大的插入变慢? 有没有什么办法,以提高该大量数据的?

Is there a problem with the size of the table? When it gets bigger the inserts get slower? Is there any way to improve the performance for that large amount of data?

感谢您的帮助。

推荐答案

有一个很好的线程在这个问题的如何提高SQLite的性能?这是相当不错的。我会去,至少在$ P $,如果你不使用它们已经ppared声明。

There is an excellent thread covering SQLite performance in the question How Do I Improve The Performance of SQLite? which is quite good. I would go for at least the prepared statements if you are not using them already.

不过,因为你是在Android上,我猜测,你可能会为一些I / O瓶颈写入到闪存运行研究。尝试运行的一对夫妇来自不同厂商的不同设备的code也看看是否有任何极端的变化。

However, as you are on Android, I am guessing that you might be running in to some I/O bottlenecks writing to flash memory. Try running the code on a couple of different devices from different manufacturers too see if there is any extreme variation.

这篇关于SQLite的插入变慢甚至与交易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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