3

I'm committed along the route of using SQLite without core data.

I need to speed up a function which performs some database transactions after querying the database. I've created a dictionary for the rows with all the values I'll need.

I need to do this to avoid the database locking.

At the moment I'm calling my add record to database function, which opens and closes the database each time.

Obviously this is where the process is slow.

I was thinking that it's common for apps to be embedded with a database setup script, so it must be possible to run a batch of queries.

So I'm thinking if I can build up a string with all my queries I could just execute that.

But I'm not 100% this is the best approach or how to execute batch queries.

Can anyone advise me how to proceed?

Jules
  • 7,568
  • 14
  • 102
  • 186
  • Either by not using a database at all and trying a different approach (like putting your data (compressed, fe with snappy) in memory and writing to the disk it when your app is closed) or by reducing the number of calls/cells (important step: always rethink your infrastructure and be sure only that only the ones that are absolutely necessary will be saved). It will be a hard challenge to optimize the speed "behind" the SQLite API. – Paul Feb 20 '12 at 20:45

2 Answers2

1

For starters .. check out these links:

how-do-i-improve-the-performance-of-sqlite

ios-coredata-batch-insert (Yes I know that you said no core data - but it is worth a read)

fast-bulk-inserts-into-sqlite (Looks similar in content to the first link)

Community
  • 1
  • 1
Peter M
  • 7,309
  • 3
  • 50
  • 91
0

I was about to do the same - using plain SQLite instead of CoreData - but changed my mind later. In that process if found this link useful: Improve INSERT-per-second performance of SQLite? . Beyond the obvious (transaction,prepared statement,..) it uses some SQLite specific performance tweaks.

Community
  • 1
  • 1
hburde
  • 1,441
  • 11
  • 6