0

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?

halfer
  • 19,824
  • 17
  • 99
  • 186

3 Answers3

3

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.

Amit
  • 1,043
  • 1
  • 10
  • 32
  • hi thanks for the answer, can you give me example like how i can fetch next 50 items. Actually m writing query like "select * from table". Can i apply ur concept in this case? – Sudha Chandran B.C. Apr 26 '13 at 02:48
  • Yes you can, in tableview delegate: cellForRowAtIndexPath check something like: if(indexPath.row == counterVariable){//fetch next 50 and append in your mutable array}...... for fetching 50 data per page you can use select * from table limit 50 and for next time select * from table limit 50,100 and so on (not very sure on query plz check more web). – Amit Apr 26 '13 at 05:40
0

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Deepak
  • 348
  • 4
  • 14
-2

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

Pratik
  • 30,639
  • 18
  • 84
  • 159