开发者

Can I run iPad with 200 thousand record with sqlite?

Current database have 200 thousand record. I want to make iPad application , can I run 200 thousand record with sqlite ? I don't want to use sqlite because searching is too slow over 32000. Any search engine like lucene for iPhone SDK ? if we can run lucene in iPad that will be awesome because current project is base on lucene. Can you g开发者_开发百科ive me a suggestion ?

Thank You


I suggest to build you own fulltext index. I don't think SQLite on the iPhone supports triggers, but you can still use a similar algorithm than the H2 fulltext search implementation. The idea is to split the text data into words, and then add those to an table that is indexed on the word. The algorithm for building the index is relatively simple. The native H2 fulltext search doesn't have all the features the Lucene fulltext search has, but it's much simpler to implement.


I recently built an iPhone app with 86,000 rows and SQLite.

At first I didn't index my serach row and searches were taking about 1 second to execut on an iPod touch 2nd generation. Once I added my indexes searching was instant.

To be honest you might be able to get away with "like" queries on the field you are looking for? It might actually be good enough. I think you will find that once you add indexes to your data, the database is really going to grow in size and could make you app pretty big and putting a full blown search engine in there could be a real pain.

Here is some code to quickly do some tests for a SQLite database.

http://www.rvaidya.com/blog/iphone/2009/02/14/wrapper-classes-for-using-sqlite-on-iphonecocoa/

SQLiteResult *result = [SQLite query:@"SELECT * from test;"];
NSArray *row = [result.rows objectAtIndex:0];
NSString *firstValue = [row objectAtIndex:0];


This blog post describes a port of Lucene to Objective C. You may try to use the code, though it seems a bit dated.


I understand Lucene is written in Java - that'd mean you can't use it on the iPad.

Have you actually created indexes in your Sqlite database? In my experience Sqlite is really quite fast. If Core Data is too slow you could also try using the native C API.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜