{"id":7011,"date":"2026-07-03T11:10:22","date_gmt":"2026-07-03T03:10:22","guid":{"rendered":"https:\/\/nullthought.net\/?p=7011"},"modified":"2026-07-03T11:17:36","modified_gmt":"2026-07-03T03:17:36","slug":"%e5%b0%8f%e3%80%81%e5%bf%ab%e3%80%81%e7%a8%b3%e7%9a%84sqlite%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/nullthought.net\/?p=7011","title":{"rendered":"\u5c0f\u3001\u5feb\u3001\u7a33\u7684SQLite\u6570\u636e\u5e93"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">SQLite \u6570\u636e\u5e93\u53e3\u7891\u597d\uff0c\u662f\u6709\u9053\u7406\u7684\u3002\u6211\u7684\u8bc4\u4ef7\u662f\uff1a<strong>\u5b83\u4e0d\u662f\u201c\u5c0f\u73a9\u5177\u6570\u636e\u5e93\u201d\uff0c\u800c\u662f\u975e\u5e38\u6210\u719f\u3001\u53ef\u9760\u3001\u9002\u5408\u5d4c\u5165\u5f0f\u548c\u672c\u5730\u5e94\u7528\u7684\u6570\u636e\u5b58\u50a8\u65b9\u6848\uff1b\u4f46\u5b83\u4e5f\u4e0d\u662f MySQL\/PostgreSQL \u90a3\u79cd\u591a\u7528\u6237\u9ad8\u5e76\u53d1\u670d\u52a1\u7aef\u6570\u636e\u5e93\u7684\u66ff\u4ee3\u54c1\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SQLite \u7684\u6838\u5fc3\u4f18\u70b9\u662f\uff1a<strong>\u5c0f\u3001\u5feb\u3001\u7a33\u3001\u514d\u7ef4\u62a4<\/strong>\u3002\u5b98\u65b9\u5bf9\u5b83\u7684\u5b9a\u4f4d\u5c31\u662f\u4e00\u4e2a\u201c\u81ea\u5305\u542b\u3001\u65e0\u670d\u52a1\u5668\u3001\u96f6\u914d\u7f6e\u3001\u4e8b\u52a1\u578b SQL \u6570\u636e\u5e93\u5f15\u64ce\u201d\uff0c\u800c\u4e14\u4ee3\u7801\u662f\u516c\u6709\u9886\u57df\uff0c\u53ef\u514d\u8d39\u7528\u4e8e\u5546\u4e1a\u6216\u79c1\u4eba\u7528\u9014\u3002SQLite \u4e5f\u81ea\u79f0\u662f\u4e16\u754c\u4e0a\u90e8\u7f72\u6700\u5e7f\u6cdb\u7684\u6570\u636e\u5e93\u4e4b\u4e00\uff0c\u88ab\u5185\u7f6e\u5728\u624b\u673a\u3001\u7535\u8111\u548c\u5927\u91cf\u5e94\u7528\u4e2d\u3002(<a href=\"https:\/\/www.sqlite.org\/about.html?utm_source=chatgpt.com\">SQLite\u5b98\u7f51<\/a>)<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"1421\" src=\"https:\/\/nullthought.net\/wp-content\/uploads\/2026\/07\/sqlite-summary.jpg\" alt=\"\" class=\"wp-image-7012\" srcset=\"https:\/\/nullthought.net\/wp-content\/uploads\/2026\/07\/sqlite-summary.jpg 800w, https:\/\/nullthought.net\/wp-content\/uploads\/2026\/07\/sqlite-summary-169x300.jpg 169w, https:\/\/nullthought.net\/wp-content\/uploads\/2026\/07\/sqlite-summary-576x1024.jpg 576w, https:\/\/nullthought.net\/wp-content\/uploads\/2026\/07\/sqlite-summary-768x1364.jpg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">\u5c0f\u3001\u5feb\u3001\u7a33\u7684SQLite\u6570\u636e\u5e93<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b83\u7279\u522b\u9002\u5408\u8fd9\u4e9b\u573a\u666f\uff1a\u684c\u9762\u8f6f\u4ef6\u3001\u672c\u5730\u5de5\u5177\u3001\u79fb\u52a8 App\u3001\u5d4c\u5165\u5f0f\u8bbe\u5907\u3001IoT \u8bbe\u5907\u3001\u8fb9\u7f18\u91c7\u96c6\u8bbe\u5907\u3001\u5355\u673a\u6570\u636e\u7f13\u5b58\u3001\u914d\u7f6e\u5b58\u50a8\u3001\u65e5\u5fd7\u7d22\u5f15\u3001\u5b9e\u9a8c\u6570\u636e\u7ba1\u7406\u7b49\u3002SQLite \u5b98\u65b9\u4e5f\u660e\u786e\u628a\u201c\u5d4c\u5165\u5f0f\u8bbe\u5907\u548c\u7269\u8054\u7f51\u201d\u5217\u4e3a\u975e\u5e38\u9002\u5408\u7684\u4f7f\u7528\u573a\u666f\uff0c\u56e0\u4e3a\u5b83\u4e0d\u9700\u8981\u6570\u636e\u5e93\u7ba1\u7406\u5458\u3001\u4e0d\u9700\u8981\u5355\u72ec\u5b89\u88c5\u6570\u636e\u5e93\u670d\u52a1\uff0c\u975e\u5e38\u9002\u5408\u65e0\u4eba\u503c\u5b88\u8bbe\u5907\u3002(<a href=\"https:\/\/sqlite.org\/whentouse.html?utm_source=chatgpt.com\">SQLite\u5b98\u7f51<\/a>)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5de5\u4e1a\u8bbe\u5907\u76d1\u6d4b\u573a\u666f\u4e2d\uff0cSQLite \u5f88\u5408\u9002\u3002\u6bd4\u5982\u5b58\u50a8\u4efb\u52a1\u4fe1\u606f\u3001\u91c7\u6837\u6458\u8981\u3001\u4e8b\u4ef6\u8bb0\u5f55\u3001\u62a5\u8b66\u8bb0\u5f55\u3001\u6a21\u578b\u8bc6\u522b\u7ed3\u679c\u3001\u4f20\u611f\u5668\u6570\u636e\u7d22\u5f15\u3001\u77ed\u671f\u539f\u59cb\u91c7\u6837\u6570\u636e\uff0c\u90fd\u53ef\u4ee5\u7528 SQLite\u3002\u5b83\u7684\u5355\u6587\u4ef6\u6570\u636e\u5e93\u4e5f\u4fbf\u4e8e\u5907\u4efd\u3001\u62f7\u8d1d\u3001\u5bfc\u51fa\u3001\u73b0\u573a\u6392\u67e5\uff0c\u914d\u5408 Qt\/C++\u3001Python \u90fd\u5f88\u65b9\u4fbf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46 SQLite \u7684\u77ed\u677f\u4e5f\u8981\u660e\u786e\uff1a<strong>\u5199\u5e76\u53d1\u80fd\u529b\u6709\u9650<\/strong>\u3002\u5b83\u53ef\u4ee5\u6709\u591a\u4e2a\u8bfb\u8005\uff0c\u4f46\u5199\u5165\u672c\u8d28\u4e0a\u662f\u4e32\u884c\u7684\u3002\u5b98\u65b9\u6587\u6863\u8bf4\u660e\uff0c\u5199\u5165\u6570\u636e\u5e93\u6587\u4ef6\u65f6\u9700\u8981\u6392\u4ed6\u9501\uff1bWAL \u6a21\u5f0f\u53ef\u4ee5\u6539\u5584\u5e76\u53d1\uff0c\u4f7f\u8bfb\u5199\u53ef\u4ee5\u540c\u65f6\u8fdb\u884c\uff0c\u4f46\u5e76\u4e0d\u7b49\u4e8e\u652f\u6301\u591a\u4e2a\u5199\u5165\u8005\u540c\u65f6\u5199\u3002(<a href=\"https:\/\/sqlite.org\/lockingv3.html?utm_source=chatgpt.com\">SQLite\u5b98\u7f51<\/a>)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\uff0c\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u662f\u8fd9\u6837\u7684\uff1a\u4e00\u4e2a\u91c7\u96c6\u7ebf\u7a0b\u6301\u7eed\u5199\u5165\uff0c\u4e00\u4e2a UI \u7ebf\u7a0b\u67e5\u8be2\u663e\u793a\uff0c\u4e00\u4e2a\u5bfc\u51fa\u7ebf\u7a0b\u5076\u5c14\u8bfb\u53d6\uff0cSQLite \u5f88\u5408\u9002\uff1b\u4f46\u5982\u679c\u662f\u51e0\u5341\u4e2a\u5ba2\u6237\u7aef\u3001\u591a\u4e2a\u8fdb\u7a0b\u3001\u591a\u4e2a\u670d\u52a1\u540c\u65f6\u9ad8\u9891\u5199\u5165\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u90a3\u5c31\u4e0d\u9002\u5408\uff0c\u5e94\u8be5\u8003\u8651 PostgreSQL\u3001MySQL\u3001TimescaleDB\u3001InfluxDB \u7b49\u670d\u52a1\u7aef\u6570\u636e\u5e93\u6216\u65f6\u5e8f\u6570\u636e\u5e93\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u91c7\u6837\u6570\u636e\uff0c\u5c24\u5176\u662f 1000Hz \u52a0\u901f\u5ea6\u8fd9\u7c7b\u9ad8\u9891\u6570\u636e\uff0cSQLite \u4e5f\u80fd\u7528\uff0c\u4f46\u8981\u6ce8\u610f\u65b9\u6cd5\u3002\u4e0d\u8981\u6bcf\u4e2a\u91c7\u6837\u70b9\u5355\u72ec\u63d0\u4ea4\u4e00\u6b21\u4e8b\u52a1\uff0c\u800c\u5e94\u8be5\u4f7f\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRAGMA journal_mode=WAL;\nPRAGMA synchronous=NORMAL;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e76\u4e14\u91c7\u7528<strong>\u6279\u91cf\u63d2\u5165\u3001\u9884\u7f16\u8bd1 SQL\u3001\u4e8b\u52a1\u63d0\u4ea4\u3001\u5408\u7406\u7d22\u5f15<\/strong>\u3002\u4f8b\u5982\u6bcf 100 \u6761\u3001500 \u6761\u30011000 \u6761\u6837\u672c\u6279\u91cf\u5199\u4e00\u6b21\uff0c\u6bd4\u9010\u6761\u63d0\u4ea4\u7a33\u5b9a\u5f97\u591a\u3002\u539f\u59cb\u6ce2\u5f62\u6570\u636e\u91cf\u7279\u522b\u5927\u65f6\uff0c\u4e5f\u53ef\u4ee5\u8003\u8651\u201cSQLite \u5b58\u4efb\u52a1\u548c\u7d22\u5f15\uff0cCSV\/\u4e8c\u8fdb\u5236\u6587\u4ef6\u5b58\u5927\u5757\u539f\u59cb\u6ce2\u5f62\u201d\u7684\u6df7\u5408\u65b9\u6848\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u7684\u603b\u4f53\u5224\u65ad\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7ef4\u5ea6<\/th><th>\u8bc4\u4ef7<\/th><\/tr><\/thead><tbody><tr><td>\u7a33\u5b9a\u6027<\/td><td>\u5f88\u9ad8<\/td><\/tr><tr><td>\u6613\u90e8\u7f72<\/td><td>\u6781\u9ad8<\/td><\/tr><tr><td>\u7ef4\u62a4\u6210\u672c<\/td><td>\u6781\u4f4e<\/td><\/tr><tr><td>\u67e5\u8be2\u80fd\u529b<\/td><td>\u5bf9\u672c\u5730\u5e94\u7528\u8db3\u591f\u5f3a<\/td><\/tr><tr><td>\u5d4c\u5165\u5f0f\u9002\u914d<\/td><td>\u975e\u5e38\u597d<\/td><\/tr><tr><td>\u591a\u7528\u6237\u9ad8\u5e76\u53d1<\/td><td>\u4e0d\u9002\u5408<\/td><\/tr><tr><td>\u9ad8\u9891\u91c7\u6837\u539f\u59cb\u6570\u636e<\/td><td>\u53ef\u4ee5\u7528\uff0c\u4f46\u8981\u6279\u91cf\u5199\u5165\u548c\u63a7\u5236\u5e93\u5927\u5c0f<\/td><\/tr><tr><td>\u5de5\u4e1a\u73b0\u573a\u8bbe\u5907<\/td><td>\u5f88\u9002\u5408\u672c\u5730\u7f13\u5b58\u3001\u4efb\u52a1\u8bb0\u5f55\u3001\u7ed3\u679c\u5b58\u50a8<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ed3\u8bba\uff1a<strong>SQLite \u7684\u597d\u53e3\u7891\u4e3b\u8981\u6765\u81ea\u201c\u53ef\u9760\u3001\u7b80\u5355\u3001\u5c11\u51fa\u95ee\u9898\u201d\u3002\u5b83\u6700\u5f3a\u7684\u5730\u65b9\u4e0d\u662f\u5927\u89c4\u6a21\u5e76\u53d1\uff0c\u800c\u662f\u5355\u673a\u3001\u672c\u5730\u3001\u5d4c\u5165\u5f0f\u3001\u8fb9\u7f18\u7aef\u573a\u666f\u4e2d\u7684\u7a33\u5b9a\u548c\u7701\u5fc3\u3002<\/strong> \u5bf9\u4f60\u7684\u8bbe\u5907\u76d1\u6d4b\u7c7b\u8f6f\u4ef6\u6765\u8bf4\uff0cSQLite \u662f\u4e00\u4e2a\u5f88\u597d\u7684\u9ed8\u8ba4\u9009\u62e9\uff1b\u53ea\u8981\u907f\u514d\u201c\u591a\u7ebf\u7a0b\/\u591a\u8fdb\u7a0b\u540c\u65f6\u9ad8\u9891\u5199\u5165\u540c\u4e00\u4e2a\u5e93\u201d\u8fd9\u79cd\u8bef\u7528\uff0c\u5b83\u5b8c\u5168\u53ef\u4ee5\u4f5c\u4e3a\u6b63\u5f0f\u4ea7\u54c1\u7684\u6570\u636e\u5b58\u50a8\u65b9\u6848\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading has-text-align-center alignwide\">WAL \u6a21\u5f0f\u7b80\u4ecb<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">WAL \u662f <strong>Write-Ahead Logging<\/strong> \u7684\u7f29\u5199\uff0c\u4e2d\u6587\u901a\u5e38\u53eb <strong>\u9884\u5199\u65e5\u5fd7\u6a21\u5f0f<\/strong>\u3002\u5728 SQLite \u91cc\uff0c\u5b83\u662f\u4e00\u79cd\u65e5\u5fd7\u673a\u5236\uff0c\u7528\u6765\u63d0\u9ad8\u6570\u636e\u5e93\u7684\u8bfb\u5199\u5e76\u53d1\u80fd\u529b\u548c\u5199\u5165\u6548\u7387\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SQLite \u9ed8\u8ba4\u5e38\u89c1\u6a21\u5f0f\u662f <strong>Rollback Journal \u56de\u6eda\u65e5\u5fd7\u6a21\u5f0f<\/strong>\u3002\u5728\u8fd9\u79cd\u6a21\u5f0f\u4e0b\uff0c\u5199\u5165\u6570\u636e\u524d\uff0cSQLite \u4f1a\u5148\u628a\u539f\u6765\u7684\u9875\u9762\u5185\u5bb9\u4fdd\u5b58\u5230\u4e00\u4e2a journal \u6587\u4ef6\u91cc\uff1b\u5982\u679c\u5199\u5165\u5931\u8d25\uff0c\u5c31\u7528 journal \u6587\u4ef6\u6062\u590d\u539f\u72b6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u800c WAL \u6a21\u5f0f\u7684\u601d\u8def\u4e0d\u4e00\u6837\uff1a<strong>\u4e0d\u76f4\u63a5\u4fee\u6539\u4e3b\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u800c\u662f\u5148\u628a\u53d8\u66f4\u5199\u5230\u4e00\u4e2a\u5355\u72ec\u7684 WAL \u65e5\u5fd7\u6587\u4ef6\u4e2d<\/strong>\u3002\u8bfb\u64cd\u4f5c\u4ecd\u7136\u53ef\u4ee5\u8bfb\u53d6\u4e3b\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u540c\u65f6\u7ed3\u5408 WAL \u6587\u4ef6\u4e2d\u7684\u6700\u65b0\u53d8\u66f4\u5f97\u5230\u6b63\u786e\u7ed3\u679c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u666e\u901a\u6a21\u5f0f\uff1a\n\u5199\u5165\u65f6\u76f4\u63a5\u6539\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u9700\u8981\u66f4\u5f3a\u7684\u9501\u63a7\u5236\u3002\n\nWAL \u6a21\u5f0f\uff1a\n\u5148\u628a\u4fee\u6539\u5199\u5230 .wal \u65e5\u5fd7\u6587\u4ef6\uff1b\n\u4e4b\u540e\u518d\u62e9\u673a\u5408\u5e76\u56de\u4e3b\u6570\u636e\u5e93\u6587\u4ef6\u3002\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u542f\u7528 WAL \u540e\uff0c\u4e00\u4e2a SQLite \u6570\u636e\u5e93\u901a\u5e38\u4f1a\u51fa\u73b0\u8fd9\u4e9b\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>data.db        \u4e3b\u6570\u636e\u5e93\u6587\u4ef6\ndata.db-wal    WAL \u65e5\u5fd7\u6587\u4ef6\ndata.db-shm    \u5171\u4eab\u5185\u5b58\u8f85\u52a9\u6587\u4ef6\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">WAL \u6a21\u5f0f\u6700\u5927\u7684\u597d\u5904\u662f\uff1a<strong>\u8bfb\u548c\u5199\u53ef\u4ee5\u66f4\u597d\u5730\u5e76\u884c<\/strong>\u3002\u5728\u4f20\u7edf\u6a21\u5f0f\u4e0b\uff0c\u5199\u5165\u65f6\u5bb9\u6613\u963b\u585e\u8bfb\u53d6\uff1b\u800c WAL \u6a21\u5f0f\u4e0b\uff0c\u5199\u5165\u8ffd\u52a0\u5230 WAL \u6587\u4ef6\uff0c\u8bfb\u53d6\u8005\u901a\u5e38\u8fd8\u80fd\u7ee7\u7eed\u8bfb\u53d6\u6570\u636e\u5e93\u5feb\u7167\u3002\u56e0\u6b64\u5bf9\u4e8e\u201c\u4e00\u4e2a\u7ebf\u7a0b\u6301\u7eed\u5199\u5165\uff0c\u53e6\u4e00\u4e2a\u7ebf\u7a0b\u67e5\u8be2\u663e\u793a\u201d\u7684\u672c\u5730\u5e94\u7528\uff0cWAL \u5f88\u6709\u4ef7\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b83\u7684\u5178\u578b\u4f18\u70b9\u6709\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u4f18\u70b9<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>\u8bfb\u5199\u5e76\u53d1\u66f4\u597d<\/td><td>\u5199\u5165\u65f6\u4e0d\u5bb9\u6613\u963b\u585e\u8bfb\u53d6<\/td><\/tr><tr><td>\u5199\u5165\u6027\u80fd\u901a\u5e38\u66f4\u597d<\/td><td>\u5199\u5165\u662f\u8ffd\u52a0\u65e5\u5fd7\uff0c\u987a\u5e8f\u5199\u5165\u6548\u7387\u8f83\u9ad8<\/td><\/tr><tr><td>\u5d29\u6e83\u6062\u590d\u53ef\u9760<\/td><td>\u6570\u636e\u5148\u5199\u65e5\u5fd7\uff0c\u5f02\u5e38\u65ad\u7535\u540e\u53ef\u6062\u590d<\/td><\/tr><tr><td>\u9002\u5408\u672c\u5730\u5e94\u7528<\/td><td>\u5f88\u9002\u5408\u684c\u9762\u8f6f\u4ef6\u3001\u5d4c\u5165\u5f0f\u8bbe\u5907\u3001\u8bbe\u5907\u76d1\u6d4b\u3001\u65e5\u5fd7\u8bb0\u5f55\u7b49\u573a\u666f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46\u8981\u6ce8\u610f\uff0cWAL \u5e76\u4e0d\u662f\u8ba9 SQLite \u53d8\u6210\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u6570\u636e\u5e93\u3002\u5b83\u4ecd\u7136\u6709\u4e00\u4e2a\u91cd\u8981\u9650\u5236\uff1a<strong>\u540c\u4e00\u65f6\u95f4\u901a\u5e38\u4ecd\u7136\u53ea\u6709\u4e00\u4e2a\u5199\u5165\u8005<\/strong>\u3002\u4e5f\u5c31\u662f\u8bf4\uff0cWAL \u6539\u5584\u7684\u662f\u201c\u8bfb\u5199\u5e76\u53d1\u201d\uff0c\u4e0d\u662f\u201c\u591a\u4e2a\u5199\u7ebf\u7a0b\u540c\u65f6\u9ad8\u9891\u5199\u5165\u201d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u542f\u7528\u65b9\u5f0f\u5f88\u7b80\u5355\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRAGMA journal_mode=WAL;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e38\u89c1\u642d\u914d\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRAGMA journal_mode=WAL;\nPRAGMA synchronous=NORMAL;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5176\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRAGMA synchronous=NORMAL;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8868\u793a\u5728\u6027\u80fd\u548c\u5b89\u5168\u4e4b\u95f4\u505a\u4e00\u4e2a\u8f83\u597d\u7684\u5e73\u8861\u3002\u5bf9\u4e8e\u5f88\u591a\u672c\u5730\u5e94\u7528\u548c\u8bbe\u5907\u76d1\u6d4b\u7cfb\u7edf\uff0c\u8fd9\u4e2a\u7ec4\u5408\u6bd4\u8f83\u5e38\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">WAL \u6a21\u5f0f\u8fd8\u6709\u4e00\u4e2a\u6982\u5ff5\u53eb <strong>checkpoint<\/strong>\uff0c\u4e2d\u6587\u53ef\u7406\u89e3\u4e3a\u201c\u68c0\u67e5\u70b9\u201d\u6216\u201c\u5408\u5e76\u70b9\u201d\u3002\u56e0\u4e3a\u6570\u636e\u5148\u5199\u5165 <code>.wal<\/code> \u6587\u4ef6\uff0cSQLite \u9700\u8981\u5728\u5408\u9002\u7684\u65f6\u5019\u628a WAL \u6587\u4ef6\u91cc\u7684\u5185\u5bb9\u5408\u5e76\u56de\u4e3b\u6570\u636e\u5e93\u6587\u4ef6\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5c31\u53eb checkpoint\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u4ee5\u624b\u52a8\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRAGMA wal_checkpoint;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u53ef\u4ee5\u6267\u884c\u66f4\u5f7b\u5e95\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRAGMA wal_checkpoint(TRUNCATE);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u540e\u8005\u4f1a\u5c3d\u91cf\u628a WAL \u5185\u5bb9\u5408\u5e76\u56de\u4e3b\u5e93\uff0c\u5e76\u622a\u65ad WAL \u6587\u4ef6\uff0c\u907f\u514d <code>.wal<\/code> \u6587\u4ef6\u957f\u671f\u53d8\u5927\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u5efa\u8bae\u8fd9\u6837\u7406\u89e3 WAL\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>WAL = \u5148\u5199\u65e5\u5fd7\uff0c\u518d\u5408\u5e76\u6570\u636e\u5e93\u3002\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b83\u7279\u522b\u9002\u5408\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4e00\u4e2a\u91c7\u96c6\u7ebf\u7a0b\u6301\u7eed\u5199\u5165\u6570\u636e\uff1b\n\u4e00\u4e2a\u754c\u9762\u7ebf\u7a0b\u5b9e\u65f6\u67e5\u8be2\u663e\u793a\uff1b\n\u4e00\u4e2a\u5bfc\u51fa\u7ebf\u7a0b\u5076\u5c14\u8bfb\u53d6\u5386\u53f2\u6570\u636e\u3002\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u7c7b\u573a\u666f\u4e2d\uff0cWAL \u53ef\u4ee5\u51cf\u5c11\u201c\u5199\u5165\u65f6\u754c\u9762\u67e5\u8be2\u5361\u4f4f\u201d\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0d\u8fc7\u4f7f\u7528 WAL \u65f6\u4e5f\u8981\u6ce8\u610f\u51e0\u70b9\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u6ce8\u610f\u70b9<\/th><th>\u8bf4\u660e<\/th><\/tr><\/thead><tbody><tr><td>\u4e0d\u8981\u591a\u4e2a\u8fdb\u7a0b\u75af\u72c2\u5199\u540c\u4e00\u4e2a\u5e93<\/td><td>SQLite \u4ecd\u7136\u4e0d\u662f\u9ad8\u5e76\u53d1\u670d\u52a1\u7aef\u6570\u636e\u5e93<\/td><\/tr><tr><td>\u4e0d\u8981\u6bcf\u6761\u6570\u636e\u5355\u72ec\u63d0\u4ea4\u4e8b\u52a1<\/td><td>\u9ad8\u9891\u6570\u636e\u5e94\u6279\u91cf\u5199\u5165<\/td><\/tr><tr><td>\u6ce8\u610f WAL \u6587\u4ef6\u5927\u5c0f<\/td><td>\u5fc5\u8981\u65f6\u505a checkpoint<\/td><\/tr><tr><td>\u6570\u636e\u5e93\u6587\u4ef6\u3001wal\u3001shm \u8981\u4e00\u8d77\u770b\u5f85<\/td><td>\u8fd0\u884c\u4e2d\u4e0d\u80fd\u53ea\u590d\u5236 <code>.db<\/code> \u6587\u4ef6\u800c\u5ffd\u7565 <code>.wal<\/code><\/td><\/tr><tr><td>\u7f51\u7edc\u6587\u4ef6\u7cfb\u7edf\u614e\u7528<\/td><td>SQLite \u5b98\u65b9\u957f\u671f\u4e0d\u5efa\u8bae\u5728\u4e0d\u53ef\u9760\u7684\u7f51\u7edc\u6587\u4ef6\u7cfb\u7edf\u4e0a\u4f7f\u7528\u590d\u6742\u9501\u673a\u5236<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u8bbe\u5907\u76d1\u6d4b\u7c7b\u8f6f\u4ef6\uff0c\u6211\u7684\u5efa\u8bae\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>PRAGMA journal_mode=WAL;\nPRAGMA synchronous=NORMAL;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u91c7\u7528\u6279\u91cf\u63d2\u5165\uff0c\u4f8b\u5982\u6bcf 100 \u6761\u3001500 \u6761\u6216 1000 \u6761\u6570\u636e\u63d0\u4ea4\u4e00\u6b21\u4e8b\u52a1\uff0c\u800c\u4e0d\u662f\u6bcf\u6761\u6570\u636e\u5355\u72ec\u63d0\u4ea4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u793a\u610f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>BEGIN TRANSACTION;\n\nINSERT INTO samples(time_ms, value) VALUES (...);\nINSERT INTO samples(time_ms, value) VALUES (...);\nINSERT INTO samples(time_ms, value) VALUES (...);\n\nCOMMIT;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a<strong>WAL \u6a21\u5f0f\u5c31\u662f SQLite \u7684\u201c\u8ffd\u52a0\u65e5\u5fd7\u5199\u5165\u6a21\u5f0f\u201d\uff0c\u5b83\u80fd\u660e\u663e\u6539\u5584\u672c\u5730\u6570\u636e\u5e93\u7684\u8bfb\u5199\u5e76\u53d1\u8868\u73b0\uff0c\u7279\u522b\u9002\u5408\u672c\u5730\u5e94\u7528\u3001\u5d4c\u5165\u5f0f\u8bbe\u5907\u548c\u8bbe\u5907\u76d1\u6d4b\u573a\u666f\uff1b\u4f46\u5b83\u4e0d\u80fd\u628a SQLite \u53d8\u6210 MySQL\/PostgreSQL \u90a3\u6837\u7684\u591a\u7528\u6237\u9ad8\u5e76\u53d1\u670d\u52a1\u7aef\u6570\u636e\u5e93\u3002<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQLite \u6570\u636e\u5e93\u53e3\u7891\u597d\uff0c\u662f\u6709\u9053\u7406\u7684\u3002\u6211\u7684\u8bc4\u4ef7\u662f\uff1a\u5b83\u4e0d\u662f\u201c\u5c0f\u73a9\u5177\u6570\u636e\u5e93\u201d\uff0c\u800c\u662f\u975e\u5e38\u6210\u719f\u3001\u53ef\u9760\u3001\u9002\u5408\u5d4c\u5165\u5f0f\u548c\u672c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[3,8],"tags":[40],"class_list":["post-7011","post","type-post","status-publish","format-standard","hentry","category-it","category-tech","tag-iot"],"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"NullThought","author_link":"https:\/\/nullthought.net\/?author=1"},"rttpg_comment":0,"rttpg_category":"<a href=\"https:\/\/nullthought.net\/?cat=3\" rel=\"category\">IT<\/a> <a href=\"https:\/\/nullthought.net\/?cat=8\" rel=\"category\">Tech<\/a>","rttpg_excerpt":"SQLite \u6570\u636e\u5e93\u53e3\u7891\u597d\uff0c\u662f\u6709\u9053\u7406\u7684\u3002\u6211\u7684\u8bc4\u4ef7\u662f\uff1a\u5b83\u4e0d\u662f\u201c\u5c0f\u73a9\u5177\u6570\u636e\u5e93\u201d\uff0c\u800c\u662f\u975e\u5e38\u6210\u719f\u3001\u53ef\u9760\u3001\u9002\u5408\u5d4c\u5165\u5f0f\u548c\u672c&hellip;","_links":{"self":[{"href":"https:\/\/nullthought.net\/index.php?rest_route=\/wp\/v2\/posts\/7011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nullthought.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nullthought.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nullthought.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nullthought.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7011"}],"version-history":[{"count":2,"href":"https:\/\/nullthought.net\/index.php?rest_route=\/wp\/v2\/posts\/7011\/revisions"}],"predecessor-version":[{"id":7015,"href":"https:\/\/nullthought.net\/index.php?rest_route=\/wp\/v2\/posts\/7011\/revisions\/7015"}],"wp:attachment":[{"href":"https:\/\/nullthought.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nullthought.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nullthought.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}