4

I use in my iPhone application a very big database. An index is used on one of its columns in oder to make the searchs in this database faster. The problem is that this index increases the size of the database : my application is now bigger than 20 Mo requiring a wifi download (I would like to remain below 20 Mo in order to allow 3G download).

Consequently, in order to reduce the size of this database, I would like to create the index on the iPhone of the user when the application is launched for the first time.

The SQLite query I want to execute is the following one :

"CREATE INDEX INDEX_ON_MYCOLUMN ON MY_TABLE (MYCOLUMN)"

Do you know how to include this query in my XCode code ? sqlite3_something ?

By the way, how to compact programmatically the database after this operation ?

Thanks a lot for your help !

1 Answer 1

1

sqlite3_exec() will probably do what you want. You can run it on every launch instead of just the first launch (the additional times will just fail harmlessly). Of course, your launch times might become terrible.

See also VACUUM ANALYZE.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. It works with a syntax as follows : NSString *query = @"CREATE INDEX IND_MYCOLUMN ON MY_TABLE(MY_COLUMN)"; const char *sqlStatement = [query2 UTF8String]; int res = sqlite3_exec(database,sqlStatement, NULL, NULL, NULL); Nevertheless, to create an index on a very large database on the iPhone is too long ; consequently, I had to reduce its size ! Thanks again for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.