我应该在SQLite3中使用编译指示或预处理器宏吗?

时间:2023-02-08 07:12:06

Is there a performance difference in SQLite3 whether I use PRAGMAs or preprocessor macros?

不管是使用PRAGMA还是预处理器宏,SQLite3都有性能差异吗?

In my case, I wonder whether there is any difference between PRAGMA foreign_keys = ON and #define SQLITE_DEFAULT_FOREIGN_KEYS=1 regarding behavior or performance.

就我而言,我想知道PRAGMA foreign_keys = ON和#define SQLITE_DEFAULT_FOREIGN_KEYS = 1之间在行为或性能方面是否有任何区别。

I tend to use the pragma to be more flexible, but I wonder whether there is some performance loss.

我倾向于使用pragma更灵活,但我想知道是否有一些性能损失。

Additional question: Is it correct that the pragma applies to the connected database. Can there be race conditions if multiple processes/threads access the same database and set a pragma? I assume that the pragma information is stored in the sqlite3 file on the hard disk.

其他问题:pragma适用于连接的数据库是否正确。如果多个进程/线程访问同一个数据库并设置了一个pragma,是否会出现竞争条件?我假设pragma信息存储在硬盘上的sqlite3文件中。

1 个解决方案

#1


1  

There is no speed difference between the PRAGMA and the default setting.

PRAGMA和默认设置之间没有速度差异。

This setting applies not to the database but to a database connection, so multiple connections cannot affect each other.

此设置不适用于数据库,而是适用于数据库连接,因此多个连接不会相互影响。

#1


1  

There is no speed difference between the PRAGMA and the default setting.

PRAGMA和默认设置之间没有速度差异。

This setting applies not to the database but to a database connection, so multiple connections cannot affect each other.

此设置不适用于数据库,而是适用于数据库连接,因此多个连接不会相互影响。