views:

17

answers:

1

Hi All,

I am building an iPhone app which has a quite big SQLite database. In order to make it lighter I thought I could delete the Primary index, and then add it on the first launch. How is would that be possible ?

Thank you

+1  A: 

Assuming that you have verified that this is worthwhile (is the DB really that much bigger with an index than without?)

In your preferences bundle of the application, set a flag for 'first-run'. When the application runs, check for the existence of this field (and that it is set). If those conditions are met, run the indexing code. When complete, unset the flag and delete the flag.

Now, on subsequent invocations of the app, when it checks for the flag, it will not be found and so the indexing will not run again.

KevinDTimm
+1 for "measure the difference". Note that dropping the index would trade installation space for run-time speed penalty which may have user acceptance issues.
msw
especially on initial startup - the worst time to have performance issues.
KevinDTimm
Actually I just don't know how to remove or add the index on the primary key.I reduced the database weight from 50Mb to 15Mb deleting other indexes, i'm trying to improve it. Sure I won't do it if it's not worth it.
Julien