SQLite插入1000行数据居然耗时9秒。。
以下为代码

static void Main(string[] args)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
SQLiteConnection connection = new SQLiteConnection("Data Source=" + directoryName + @"\Test.db");
connection.Open();
SQLiteCommand commandClearDB = new SQLiteCommand("delete FROM highscores", connection);
commandClearDB.ExecuteNonQuery();
DateTime now = DateTime.Now;
for (int i = 0; i < 1000; i++)
{
SQLiteCommand command = new SQLiteCommand("insert into highscores (name, score) values ('Me', 3000)", connection);
command.ExecuteNonQuery();
}
SQLiteCommand commandCount = new SQLiteCommand("select count(*) from highscores", connection);
object count = commandCount.ExecuteScalar();
string tip = ((DateTime.Now - now)).TotalMilliseconds.ToString();
Console.WriteLine(tip);
Console.WriteLine("数据行:" + count);
Console.ReadKey();
}
...全文
相关推荐
SQLite 大数据测试
描述中提到的“1000W 数据 265M 213s 搞定”意味着有1000万条数据,总大小约为265MB,全部导入到SQLite数据库中仅耗时213秒。
execSQL和SQLiteStatement的executeInsert方法插入1000条数据所需要的时间对比
在Android开发中,数据库操作是常见的任务之一,SQLite作为Android内置的关系型数据库,为我们提供了方便的数据存储和管理功能。在批量插入数据时,性能优化显得尤为重要。
SQLite速度评测代码
起初,没有使用任何优化措施,导致1000条记录的插入耗时较长。然后,通过引入数据库事务,显著提升了性能。
在Titanium中通过使用BEGIN/COMMIT来加速SQLite插入操作
在Titanium开发移动应用时,SQLite数据库是一种常用的本地数据存储方式。为了提高SQLite数据库的插入操作性能,可以利用BEGIN和COMMIT事务管理命令。
C#操作SQLite数据库方法小结(创建,连接,插入,查询,删除等)
本文将深入解析C#操作SQLite数据库的方法,包括数据库的创建、连接、数据插入、查询以及删除等核心操作。SQLite是一种轻量级的、无需服务器的嵌入式数据库系统,它利用C语言编写,支持SQL92标准


其他数据库
