SQLite插入1000行数据居然耗时9秒。。

shsyzl007 shsyzl007 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
以下为代码
  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 大数据测试

SQLite 大数据量导入SQLite性能测试 较为理想 1000W 数据 265M 213s 搞定

kkskssk

execSQL和SQLiteStatement的executeInsert方法插入1000条数据所需要的时间对比

execSQL和SQLiteStatement的executeInsert方法插入1000条数据所需要的时间对比

蛋蛋君de忧伤

SQLite速度评测代码

今天有个朋友测试 SQLite,然后得出的结论是:SQLite 效率太低,批量插入1000条记录,居然耗时 2 分钟! 下面是他发给我的测试代码。我晕~~~~~~ using System.Data; using System.Data.Common; using System.Data.SQLite; // 创建数据库文件 File.Delete(“test1.db3”); SQLiteConnection.CreateFile&#40;“test1.db3”&#41;; DbProviderFactory factory = SQLiteFactory.Instance; using (DbConnect

weixin_38500607

在Titanium中通过使用BEGIN/COMMIT来加速SQLite插入操作

NULL 博文链接:https://rensanning.iteye.com/blog/1464360

weixin_38669628

C#操作SQLite数据库方法小结(创建,连接,插入,查询,删除等)

本文实例讲述了C#操作SQLite数据库方法。分享给大家供大家参考,具体如下: SQLite介绍 SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite是一个开源、免费的小型RDBMS(关系型数据库),能独立运行、无服务器、零配置、支持事物,用C实现,内存占用较小,支持绝大数的SQL92标准。 SQLite数据库官方主页:http://www.sqlite.org/index.h

weixin_38697171
评论 3
收藏 已收藏
分享
返回顶部
shsyzl007
其他数据库 2,208 成员 9,519 内容