Sudha Chandran B.C.
Sudha Chandran B.C.

Reputation: 82

Load Large Data from multiple tables in parallel using multithreading

I'm trying load data about 10K records from 6 different tables from my Ultralite DB.

I have created different functions for 6 different tables.

I have tried to load these in parallel using NSInvokeOperations, NSOperations, GCD, Subclassing NSOperation but nothing is working out.

Actually, loading 10K from 1 table takes 4 Sec, and from another 5 Sec, if i keep these 2 in queue it is taking 9 secs. This means my code is not running in parallel.

How to improve performance problem?

Upvotes: 0

Views: 317

Answers (3)

Deepak
Deepak

Reputation: 348

You should fetch records in chunks(i.e. fetch 50-60 records at a time in a table). And then when user reach end of the table load another 50 -60 records. Try hands with this library: Bottom Pull to refresh more data in a UITableView

Regarding parallelism go with GCD, and reload respective table when GCD's success block called.

Upvotes: 0

Jacob Noble
Jacob Noble

Reputation: 11

Ok you have to use Para and Time functions look them up online for more info

Upvotes: -2

Amit
Amit

Reputation: 1043

There may be multiple ways of doing it.

What i suggest will be :

  • Set the number of rows for table view to be exact count (10k in your case)
  • Table view is optimised to create only few number of cells at start(follows pull model). so cellForRowAtIndexPath will be called only for few times at start.
  • Have an array and fetch only 50 entries at start. Have a counter variable.
  • When user scrolls table view and count reaches after 50 fetch next 50 items(it will take very less time) and populate cells with next 50 data. keep on doing same thing.

Hope it works.

Upvotes: 3

Related Questions