Android的数据库索引 [英] android database indexing
问题描述
我的Android应用程序需要SQLite数据库频繁访问。我在想,如果有一种方法来索引数据库具有数据访问速度。厦人做数据库的索引在android系统?请建议我做的最好的方法?
My android application needs frequent access to sqlite database. I was thinking if there is a way to index the database to have faster access to data. Ha anyone done indexing of database in android? Please suggest me the best way to do that?
是否真的需要,因为我们对当地设备所有的数据库,甚至运行的查询,每次也不会花费太多时间。
Is it really needed as we have all the database on local device and even running query everytime will not take much time.
RGDS,
萨班
Rgds, Sapan
推荐答案
SQLite支持CREATE INDEX语句:
SQLite supports the CREATE INDEX statement:
<一个href=\"http://www.sqlite.org/lang_createindex.html\">http://www.sqlite.org/lang_createindex.html
例如:
create index foo_bar_idx on foo(bar);
有关在当一个查询规划将决定使用索引进行了深入的讨论,尝试PostgreSQL文档来代替:
For an in-depth discussion in when a query planner would decide to use an index, try the PostgreSQL documentation instead:
<一个href=\"http://www.postgresql.org/docs/9.0/static/indexes.html\">http://www.postgresql.org/docs/9.0/static/indexes.html
这不会在SQLite中完全相同的方式工作,但总的想法是一样的:
It won't work in the exact same way in SQLite, but the general ideas are the same:
- 对于微小的表,读取整个表不是通过索引扫描速度更快。
- 对于一个ORDER BY /限制,在排序中使用的字段(S)创建索引。
- 对于加入/在哪里,你要在球场上(S)的索引的位置。
使用在连接/
这篇关于Android的数据库索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!