Click here to Skip to main content
15,889,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.


VB
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
Posted
Updated 15-May-13 3:46am
v2

1 solution

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[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900