问题描述
我正在开发一款使用Android操作系统的数据库应用程序。我只是想知道哪个code执行速度更快,它们之间有什么区别呢?
查询 - 1 =
db.rawQuery(SELECT * FROM USER_TABLE,其中user_ID的=+用户id,NULL);
查询 - 2 =
db.query(USER_TABLE_NAME,ALL_COLUMNS,USER_ID =+用户id,NULL,NULL,NULL,NULL);
看着SQLiteDatabase.java在Android源代码显示,查询(..)最终调用QueryBuilder的打造查询作为一个字符串,然后将其基本要求rawQuery()。他们应该是大体相当,假设你也做了同样的工作,以建立自己的声明。
I am developing one android database application . I just want to know which code execute faster and what is the difference between them?
Query - 1 =
db.rawQuery("select * from user_table where user_id =" + userId, null);
Query - 2 =
db.query(USER_TABLE_NAME, ALL_COLUMNS, "user_id = " + userId, null, null, null, null);
Looking at SQLiteDatabase.java in the android source shows that the query(..) ends up calling the QueryBuilder to build the query as a single string and then it essentially calls rawQuery(). They should be roughly equivalent, assuming that you also did the same work to build your own statement.
这篇关于Android的SQLite的:哪个查询("查询"或" rawQuery")更快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!