Dataset.Update()到本地SQLite数据库需要很长时间 [英] Dataset.Update() to local SQLite Database takes a long time

查看:120
本文介绍了Dataset.Update()到本地SQLite数据库需要很长时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的sqlite媒体数据库需要很长时间才能在vb.net中更新(我正在使用dataset.update())。我有一个30列的主表。此表填充了其他29个表的主键。



其他29个表中的每个表都有2列。 1.主键与主表相关的列和2.列包含值。



在应用程序启动时,我打开连接一次并加载完整将所有表都放入数据集的数据库(这不是问题)。然后我为数据集中的每个表创建一个新的sqlitedataadapter并将其放入一个列表(sqlitedataadapter)(也不是问题)。



假设我的媒体数据库那里没有参赛作品。然后我添加一个包含300个mp3文件的新文件夹。



如果我在搜索过程中没有更新,则需要大约3秒钟才能添加所有文件。当我在搜索后进行更新时需要超过5秒钟,而我的硬盘工作就像疯了一样。但媒体数据库文件仅从67kbyte增长到ca. 90kbyte。



为什么更新数据库需要这么长时间?



这是代码



请注意我正在使用表,列和sqlitedataadapters的预定义列表来进行更新。特别是我正在使用for循环。





Hi all,

my sqlite media database needs a long time to update (I''m using dataset.update()) in vb.net. I have a master table with 30 columns. This table is filled with the primary keys of the other 29 tables.

Each table of the other 29 tables has 2 columns. 1. column with the primary key related to the master table and 2. column contains the value.

At application start i open the connection for one time and load the complete database with all tables into a dataset (which is not a problem). Then i create for each table in the dataset a new sqlitedataadapter and put that into a list(of sqlitedataadapter) (also not a problem).

Let say my media database has no entries in there. Then i add a new folder which contains 300 mp3 files.

When i do no update during the search it takes around 3 seconds to add all the files. When i do an update after the search it takes more than 5 seconds and my harddrive works like mad. But the media database file grows only from 67kbyte to ca. 90kbyte.

Why it takes so long to update the database?

Here is the code

Please note that I''m using predefined list(s) of tables, columns and sqlitedataadapters to do the update. Especially i''m using the for loop.


Sub DATABASE_UPDATE(Optional Table As Integer = Nothing)
	If Table = Nothing Then
		For i As Integer = 0 To MEDIATABLELIST.Count - 1
			Dim MEDIASQLITECOMMANDBUILDER As New SQLiteCommandBuilder(MEDIASQLITEDATAADAPTERLIST.Item(i))
			MEDIASQLITEDATAADAPTERLIST.Item(i).Update(MEDIADATABASE, MEDIATABLELIST.Item(i))
		Next
	Else
		Dim MEDIASQLITECOMMANDBUILDER As New SQLiteCommandBuilder(MEDIASQLITEDATAADAPTERLIST.Item(Table))
		MEDIASQLITEDATAADAPTERLIST.Item(Table).Update(MEDIADATABASE, MEDIATABLELIST.Item(Table))
	End If
End Sub

推荐答案

我永远不会在这样的任务中使用这样的模式,但是你做出了自己的选择。当你在普通PC上使用它时,你得到的时间是可以理解的。您可以尝试通过调整来最小化IO负载。请检查: http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html [ ^ ]。
I would never use a schema like this for such a task, but you made your choice. As you use this on a normal PC, the time you got is quite understandable. You could try to minimize IO load with tuning. Check this: http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html[^].


这篇关于Dataset.Update()到本地SQLite数据库需要很长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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