I read that delete operation is slow and I was wondering how can I improve this check.
I have a table which is filled by 10-15k rows every day and every startup I need to clean all records older than 6 months but when the database grows, I start to have speed problem. Close to 1 MILION of records when I run this command - EVEN if I have NOTHING to delete - the software hang for minutes....which is not acceptable:
Using cnn as New SqliteConnection(dbConnection)
cnn.Open()
dim cmd as New SQLiteCommand(cnn)
cmd.CommandText = "DELETE FROM tablename WHERE timecolumn < datetime('now', '-6 months')"
rowsUpdated = cmd.ExecuteNonQuery
End Using
This results in a few minutes of hang even if no records are deleted.
How can I do it quicker, much quicker?
I'm working on .NET compact framework 3.5 for WinCe 6
Thank you