Posted By Our Mentors
Amreen Khan
Android Developer
animesh bansal
iphone App Developer
Devendra chouksey
Android Developer
Dilip Saket
IOS apps developer
Hemraj Jhariya
iOS Developer
Jaihind singh Rajput
Smart Phone App Dev
Mujahid khan
Android developer
Narendra Yadav
android developer
Narinder Gupta
Mobile App Architect
Pradeep singh Thakur
Mobile App Architect
Sanjay Sharma
Andriod Developer
Shakti Rajpal
IT Architect
Soniya Vishwakarma
iPhone App Developer
Sunil Raghuwanshi
iPhone App Developer
Supriya Kapse
Senior developer
Reasons behind Slow process when inserting mass data into SQLite Database Iphone/iPad
Normally in any iPhone/iPad app, We download all the data after launching the application and insert it into the database. While downloading from the web services and inserting into the database we show a loading status to the user. If we have huge data so, it suppose to takes time 10-15 minutes.
Posted By: Dilip Saket Date: 22 Oct 2013 View: 2196
      Rate This !!

Sometimes a slow process keep you into the fire when you have a lot of to do but just stucked into a one place while inserting mass data into SQLite database. Okay, let me explain the entire scnario why it is going to be a bit of slow when processed in a bulk manner.

In this total process time, downloading is done in 30-120 seconds but insertion takes time more then 10 minutes Because we have number of records to insert into database. Here the point is that we have got the data in 30 seconds and showing loading status view to the user for the time data inserting in database. If we remove loading status view after parsing and inserting data in database(Its good). But, When firing some database queries, it returns a message containing database is locked while insertion is on its go.

What to do?

  • Download data :- Download data using your parser.
  • Remove downloading status view just after parsing : - (Loading…, Downloading..., etc)
  • Filter data into global variables like NSDictionary, NSArray :- This is a logic to filter your data in a way that we can fetch specific data.
  • Show filtered data in the application :- Using logical Methods which will fetch the data from the variables of previous point (or from database if data base is  not locked).
  • Insert data into database using background thread via NSOperationQueue :- This will lock the database.

Problems :
 Database will be locked until the insertion is running. So, we might not  be able to perform any database query like select, insert, update or delete.

Solution :

Put all these insert, update or delete operation in NSOperationQueue and according to operation update the global variables.

How to do this:

Example :  I will take an example. With huge amount of data and give you a sample code for this solution in next article. Thanks!!

Posted Queries
Posted By: Anees Masudi Reply:Reasons behind Slow process when inserting m
19 Feb 2018
This has been a great platform for every developer. It will surely be helpful for them.