SQLite数据库在<table_name>(列)上提供警告自动索引升级Android L后

Pra*_*ani 42 android android-logcat android-sqlite android-5.0-lollipop

我已经使用Android 5.0 Lollipop升级了我的Nexus 7,在此之前我的应用程序与SQLite数据库配合得很好但是现在每当我执行任何类型的查询时,它都会给我发送log cat错误,例如:

12-09 12:37:04.942: E/SQLiteLog(13041): (284) automatic index on area(server_id)
12-09 12:37:04.942: E/SQLiteLog(13041): (284) automatic index on account(area_id)
12-09 12:37:04.942: E/SQLiteLog(13041): (284) automatic index on staff_visit(account_id)
12-09 12:37:04.942: E/SQLiteLog(13041): (284) automatic index on ordertab(account_id)
12-09 12:37:04.960: E/SQLiteLog(13041): (284) automatic index on area(server_id)
12-09 12:37:04.960: E/SQLiteLog(13041): (284) automatic index on account(area_id)
12-09 12:37:04.960: E/SQLiteLog(13041): (284) automatic index on staff_visit(account_id)
12-09 12:37:04.960: E/SQLiteLog(13041): (284) automatic index on ordertab(account_id)
12-09 12:37:04.978: E/SQLiteLog(13041): (284) automatic index on area(server_id)
12-09 12:37:04.978: E/SQLiteLog(13041): (284) automatic index on account(area_id)
12-09 12:37:04.978: E/SQLiteLog(13041): (284) automatic index on staff_visit(account_id)
12-09 12:37:04.978: E/SQLiteLog(13041): (284) automatic index on ordertab(account_id)
Run Code Online (Sandbox Code Playgroud)

那么任何棒棒糖错误都是错误的吗?我是这么认为的,因为我在升级此操作系统之前和之后都没有更新我的代码.

laa*_*lto 71

在sqlite 3.7.17中引入了自动索引.具有此功能的sqlite版本仅包含在Android L开发人员预览中.这就是为什么你只在Lollipop上获得消息而不是更早.即使将其记录为错误,它也只是一条消息.

基本上,当您在非索引列上进行查找时,自动索引会发挥作用.sqlite假设有太多数据生成临时索引比原始查找便宜.

考虑为查询列添加显式永久索引CREATE INDEX.例如,在你之后CREATE TABLE:

CREATE INDEX indexname ON tablename(columnname);
Run Code Online (Sandbox Code Playgroud)

您可以tablename(columnname)从sqlite生成的autoindex消息中选择.

如果您只想恢复旧行为,则可以禁用自动索引

PRAGMA automatic_index=off;
Run Code Online (Sandbox Code Playgroud)

  • 当开发人员无法理解错误日志的含义时,我讨厌它...它会破坏我的logcat输出!它应该是一个信息日志或最多警告...... (5认同)
  • 我不明白的是为什么我不断收到这些消息,虽然我已经在那个表列上创建了一个索引.... (3认同)
  • @MuhammadBabar取决于数据量和读写比例. (2认同)