1

I am applying join query to fetch data from database on my iPhone app.
See my query
"select A.a1, A.a2, B.b1, B.b2, C.c1, C.c2, from A LEFT OUTER JOIN B ON A.a3 = B.b3 AND A.a4 = B.b4 LEFT OUTER JOIN C ON A.a5 = C.c3 Where A.a6 = '%@'"

Here A contains more than 30K records, B has 20K records and C contains 200 records. Is there any way to reduce the time taken to fetch the data?

NOTE : This query returns correct result.

Ankur
  • 5,086
  • 19
  • 37
  • 62
  • On probable solution is to have custom paging as I guess you will not be showing all the records to user at a time on iphone screen. Paging will take some efforts to implement but that will be the best solution for performance of the application. – Janak Nirmal Jan 30 '12 at 07:18
  • Actually, query returns 100 records max out of thousands, so I dont think paging will be a good option. :) – Ankur Jan 30 '12 at 08:20

2 Answers2

1

In this case, you can use column indexes in the table. Following links point to as to how to create the indexes in Sqlite database.

  1. creating the index
  2. Same question answered here.

This might help you.

Community
  • 1
  • 1
Nimit Parekh
  • 16,776
  • 8
  • 50
  • 72
0

did you tried indexing Table A ? if not try it.. it might be a way to reduce the time to fetch data.. Warning : using Index in wrong place may affect your performance