LoginSignup
2
2

More than 5 years have passed since last update.

AndroidでContentResolver経由しての速度調査

Last updated at Posted at 2012-11-14

AndroidのContentResolver経由でDBアクセスしたときの速度調査を行なったので、記録。

条件

  • Android 4.1.2 エミュレータ上
  • 使用URI content://com.android.browser/bookmarks
  • レコードとして20000件登録。うち10000件を削除状態(deleted=1)。

比較対象

ContentResolver#query()の第5引数"sortOrder"を
1. null
2. "_id asc"
で確認。

以下、3回実施しての平均値(ms)。

全件取得

  1. 1981
  2. 1133

10件取得(先頭から)

  1. 2219
  2. 81

100件取得(先頭から)

  1. 1441
  2. 90

1000件取得(先頭から)

  1. 1470
  2. 198

10件取得(8000件目から)

  1. 1498
  2. 223

100件取得(8000件目から)

  1. 1841
  2. 246

1000件取得(8000件目から)

  1. 1540
  2. 338

まとめ

ソートを入れない方が、全体的に検索結果が遅くなる。
さらに、取得件数や取得位置といった条件に比例した時間とならず、不安定な結果に見える。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2