SQLite.NET提供程序的选择

简介:

今日用到了SQLite,发现这个数据库进行了很大的升级,从3.4.X升级到3.5.X了。版本号发生改变,API接口OS层发生重大改变。

SQLite version 3.5.0 introduces a new OS interface layer that is incompatible with all prior versions of SQLite. In addition, a few existing interfaces have been generalized to work across all database connections within a process rather than just all connections within a thread. The purpose of this article is to describe the changes to 3.5.0 in detail so that users of prior versions of SQLite can judge what, if any, effort will be required to upgrade to newer versions.

1.0 Overview Of Changes

A quick enumeration of the changes in SQLite version 3.5.0 is provide here. Subsequent sections will describe these changes in more detail.

  1. The OS interface layer has been completely reworked:
    1. The undocumented sqlite3_os_switch() interface has been removed.
    2. The SQLITE_ENABLE_REDEF_IO compile-time flag no longer functions. I/O procedures are now always redefinable.
    3. Three new objects are defined for specifying I/O procedures: sqlite3_vfssqlite3_file, and sqlite3_io_methods.
    4. Three new interfaces are used to create alternative OS interfaces: sqlite3_vfs_register()sqlite3_vfs_unregister(), and sqlite3_vfs_find().
    5. A new interface has been added to provided additional control over the creation of new database connections: sqlite3_open_v2(). The legacy interfaces of sqlite3_open() and sqlite3_open16() continue to be fully supported.
  2. The optional shared cache and memory management features that were introduced in version 3.3.0 can now be used across multiple threads within the same process. Formerly, these extensions only applied to database connections operating within a single thread.
    1. The sqlite3_enable_shared_cache() interface now applies to all threads within a process, not to just the one thread in which it was run.
    2. The sqlite3_soft_heap_limit() interface now applies to all threads within a process, not to just the one thread in which it was run.
    3. The sqlite3_release_memory() interface will now attempt to reduce the memory usages across all database connections in all threads, not just connections in the thread where the interface is called.
    4. The sqlite3_thread_cleanup() interface has become a no-op.
  3. Restrictions on the use of the same database connection by multiple threads have been dropped. It is now safe for multiple threads to use the same database connection at the same time.
  4. There is now a compile-time option that allows an application to define alternative malloc()/free() implementations without having to modify any core SQLite code.
  5. There is now a compile-time option that allows an application to define alternative mutex implementations without having to modify any core SQLite code.

Of these changes, only 1a and 2a through 2c are incompatibilities in any formal sense. But users who have previously made custom modifications to the SQLite source (for example to add a custom OS layer for embedded hardware) might find that these changes have a larger impact. On the other hand, an important goal of these changes is to make it much easier to customize SQLite for use on different operating systems.

 

由于存储层的改变,SQLite.NET的各个版本也发生了变化:

SQLite.NET 1.0.46是最后一个基于3.4.X版本的提供程序;
SQLite.NET 1.0.48是当前最新的基于3.5.4代码的提供程序;

SQLite.NET的新版本主要是随SQLite3.4->3.5的改进而进行了相应的修改。性能有很大变化,对比如下:

1.0.46 test

Beginning Test on System.Data.SQLite.SQLiteConnection
SUCCESS - CreateTable
SUCCESS - Full Text Search
SUCCESS - DataType Test
SUCCESS - Dispose pattern test
SUCCESS - KeyInfo Fetch
SUCCESS - Transaction Enlistment
SUCCESS - Guid Test
SUCCESS - InsertTable
SUCCESS - VerifyInsert
SUCCESS - CoersionTest
SUCCESS - ParameterizedInsert
SUCCESS - BinaryInsert (using named parameter)
SUCCESS - VerifyBinaryData
SUCCESS - LockTest
SUCCESS - ParameterizedInsertMissingParams

          Inserting using CommandBuilder and DataAdapter
          -> (10,000 rows) ...
          -> Insert Ends in 210 ms ... Commits in 481 ms

          Inserting using CommandBuilder and DataAdapter
          ->(with identity fetch) (10,000 rows) ...
          -> Insert Ends in 300 ms ... Commits in 201 ms

          Fast insert using parameters and prepared statement
          -> (100,000 rows) Begins ...
          -> Ends in 801 ms ... Commits in 441 ms

          User Function iteration of 120003 records in 240 ms
          Raw iteration of 120003 records in 100 ms
          Intrinsic Function iteration of 120003 records in 70 ms

          User (text)  command executed 397517 times in 1 second.
          UserFunction command executed 570342 times in 1 second.
          Intrinsic    command executed 932032 times in 1 second.
          Intrin (txt) command executed 747247 times in 1 second.
          Raw Value    command executed 1013199 times in 1 second.

          UserAggregate executed 17 times in 1 second.

SUCCESS - UserCollation
SUCCESS - DropTable

Tests Finished.

1.0.48 test

Beginning Test on System.Data.SQLite.SQLiteConnection
SUCCESS - CreateTable
SUCCESS - Full Text Search
SUCCESS - DataType Test
SUCCESS - Dispose pattern test
SUCCESS - KeyInfo Fetch
SUCCESS - Transaction Enlistment
SUCCESS - Guid Test
SUCCESS - InsertTable
SUCCESS - VerifyInsert
SUCCESS - CoersionTest
SUCCESS - ParameterizedInsert
SUCCESS - BinaryInsert (using named parameter)
SUCCESS - VerifyBinaryData
SUCCESS - LockTest
SUCCESS - ParameterizedInsertMissingParams

          Inserting using CommandBuilder and DataAdapter
          -> (10,000 rows) ...
          -> Insert Ends in 411 ms ... Commits in 100 ms

          Inserting using CommandBuilder and DataAdapter
          ->(with identity fetch) (10,000 rows) ...
          -> Insert Ends in 440 ms ... Commits in 131 ms

          Fast insert using parameters and prepared statement
          -> (100,000 rows) Begins ...
          -> Ends in 1312 ms ... Commits in 340 ms

          User Function iteration of 120003 records in 191 ms
          Raw iteration of 120003 records in 130 ms
          Intrinsic Function iteration of 120003 records in 140 ms

          User (text)  command executed 298951 times in 1 second.
          UserFunction command executed 418648 times in 1 second.
          Intrinsic    command executed 599105 times in 1 second.
          Intrin (txt) command executed 458549 times in 1 second.
          Raw Value    command executed 655652 times in 1 second.

          UserAggregate executed 15 times in 1 second.

SUCCESS - UserCollation
SUCCESS - DropTable

Tests Finished.

由测试可知,3.4版的SQLite在很多方面,性能依然要比3.5版的SQLite强不少。但是SQLite 3.5版在OS适配层的改进(引入VFS对象),提高了数据的写入效率,明显的,其Commits的时间总是较少。

结论:
3.4版的SQLite在数据插入较多的应用情况下,效率仍然较好;
3.5版的SQLite在数据写入磁盘方面有很大改进,但其显然在内存数据组织方面还有待改进,插入操作所耗费的时间明显比3.4版要长;

感觉3.4版的SQLite是非常稳定的一个版本。3.5版,看来等等再使用了。




本文转自斯克迪亚博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2008/02/19/1074055.html,如需转载请自行联系原作者

相关文章
|
域名解析 缓存 Linux
如何让你的.NET WebAPI程序支持HTTP3?
如何让你的.NET WebAPI程序支持HTTP3?
205 2
如何让你的.NET WebAPI程序支持HTTP3?
|
XML 开发框架 .NET
LabVIEW中加载.NET 2.0,3.0和3.5程序集
LabVIEW中加载.NET 2.0,3.0和3.5程序集
300 4
|
9月前
|
算法 Java 测试技术
Benchmark.NET:让 C# 测试程序性能变得既酷又简单
Benchmark.NET是一款专为 .NET 平台设计的性能基准测试框架,它可以帮助你测量代码的执行时间、内存使用情况等性能指标。它就像是你代码的 "健身教练",帮助你找到瓶颈,优化性能,让你的应用跑得更快、更稳!希望这个小教程能让你在追求高性能的路上越走越远,享受编程带来的无限乐趣!
392 13
|
Ubuntu 持续交付 API
如何使用 dotnet pack 打包 .NET 跨平台程序集?
`dotnet pack` 是 .NET Core 的 NuGet 包打包工具,用于将代码打包成 NuGet 包。通过命令 `dotnet pack` 可生成 `.nupkg` 文件。使用 `--include-symbols` 和 `--include-source` 选项可分别创建包含调试符号和源文件的包。默认情况下,`dotnet pack` 会先构建项目,可通过 `--no-build` 跳过构建。此外,还可以使用 `--output` 指定输出目录、`-c` 设置配置等。示例展示了创建类库项目并打包的过程。更多详情及命令选项,请参考官方文档。
645 13
|
存储 运维
.NET开发必备技巧:使用Visual Studio分析.NET Dump,快速查找程序内存泄漏问题!
.NET开发必备技巧:使用Visual Studio分析.NET Dump,快速查找程序内存泄漏问题!
229 2
|
自然语言处理 C# 图形学
使用dnSpyEx对.NET Core程序集进行反编译、编辑和调试
使用dnSpyEx对.NET Core程序集进行反编译、编辑和调试
184 0
|
11月前
|
XML 存储 安全
C#开发的程序如何良好的防止反编译被破解?ConfuserEx .NET混淆工具使用介绍
C#开发的程序如何良好的防止反编译被破解?ConfuserEx .NET混淆工具使用介绍
744 0
|
Linux C# iOS开发
如何用 WinDbg 调试Linux上的 .NET程序
【7月更文挑战第13天】 1. `dotnet-dump`: Collects process dumps with `dotnet-dump collect -p <process_id>`. 2. `lldb`: Debugs Mono runtime apps on macOS/Linux. 3. **Visual Studio Code**: Remotely debugs .NET via the C# extension. 4. **JetBrains Rider**: Supports remote debugging of .NET on Linux.
189 2
|
开发框架 .NET 测试技术
.NET Core 日志记录程序和常用日志记录框架
本文主要内容为.NET Core的日志记录程序和常使用的日志记录框架的简单使用 首先,打开VS2019新建一个ASP.NET Core Web Api项目,项目创建好后会有一个集成好的天气预报的类和控制器,接下来,我们的方法就在天气控制器里完成。
187 0
|
开发框架 NoSQL .NET
使用 Asp.net core webapi 集成配置系统,提高程序的灵活和可维护性
使用 Asp.net core webapi 集成配置系统,提高程序的灵活和可维护性
164 0

热门文章

最新文章