Android数据库SQLite性能优化①.PDF
2014 年 第 23 卷 第 4 期 计 算 机 系 统 应 用
Android 数据库 SQLite 性能优化①
林培杰, 朱安南, 程树英
(福州大学 物理与信息工程学院, 福州 350108)
摘 要: SQLite 是 Android 平台的重要数据库引擎, 具有零配置、支持事务、移植性好等特点, 负责多种格式数
据的存储. 随着用户数据规模的扩大与复杂度的增加, 对数据库性能提出更高的要求. 数据库性能直接影响应用
程序的性能和用户的体验. 本文分析了 SQLite 事务机制和索引结构, 并通过手动添加事务和合理创建B-tree 索引,
大大缩短了 Android SQLite 数据库的插入与查询时间, 提高了 SQLite 性能.
关键词: Android SQLite; 性能优化; 事务; 索引
Performance Optimization of Android Database SQLite
LIN Pei-Jie, ZHU An-Nan, CHENG Shu-Ying
(College of Physics and Information Engineering, Fuzhou University , Fuzhou 350108,China)
Abstract: SQLite is an important database engine on Android platform. It has features of zero-configuration, supporting
transactions and excellent portability. And it is responsible for multiple formats of data storage. With the expansion and
complexity of the user data, there is higher demand upon the SQLite performance which may affect the performance of
the application program and the user experience. This paper analyzes the transaction mechanism and the index structure
of SQLite. By means of turning on transaction manually and creating B-tree index properly, it greatly reduces the time
needed to insert and query data from Android SQLite, which improves SQLite performance ultimately.
Key words: Android SQlite; performance optimization; transaction; index
随着嵌入式移动设备的普及和用户数据的高频存 显得尤为重要.
取 , 数 据 库 性 能 得 到 日 益 重 视 . SQLite 是 由
D.RichardHipp 开发并于 2000 年发布的一款开源、轻 1 Android SQLite简介
量级的关系型数据库, 占用极少的内存资源, 并具有 Android 在运行环境中集成了 SQLite 数据库, 可
[1]. 目前, SQlite 数据库广泛应用于主 供每个应用程序使用且无服务进程[3]. 由于支持
良好的可移植性
流的移动设备[2], 如iPhone 和Android 平台利用SQLite SQLite 的 Dalvki 虚拟机是基于 Java 的, 因此需对
数据库引擎实现结构化数据的存储, 并适用于多种数 SQLite API (Application Programming