715 lines
481 KiB
HTML
715 lines
481 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html><head><title>基本概念</title><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta property="og:title" content="基本概念"/><meta property="og:description" content="Postgresql 基本概念."/><meta property="og:image" content="https://wiki.7wate.com/static/og-image.png"/><meta property="og:width" content="1200"/><meta property="og:height" content="675"/><link rel="icon" href="../../../static/icon.png"/><meta name="description" content="Postgresql 基本概念."/><meta name="generator" content="Quartz"/><link rel="preconnect" href="https://fonts.googleapis.com"/><link rel="preconnect" href="https://fonts.gstatic.com"/><script async src="https://umami.7wate.com/script.js" data-website-id="c061efdc-95dd-4d21-9d04-a1ffda0a85b9"></script><script>
|
|||
|
var _hmt = _hmt || [];
|
|||
|
(function() {
|
|||
|
var hm = document.createElement("script");
|
|||
|
hm.src = "https://hm.baidu.com/hm.js?94d8ccb156eb7c65abf317e6e01cdba9";
|
|||
|
var s = document.getElementsByTagName("script")[0];
|
|||
|
s.parentNode.insertBefore(hm, s);
|
|||
|
})();
|
|||
|
</script><script async src="https://www.googletagmanager.com/gtag/js?id=G-MHMEL0F832"></script><script>
|
|||
|
(function() {
|
|||
|
window.dataLayer = window.dataLayer || [];
|
|||
|
function gtag() {
|
|||
|
window.dataLayer.push(arguments);
|
|||
|
}
|
|||
|
gtag('js', new Date());
|
|||
|
gtag('config', 'G-MHMEL0F832');
|
|||
|
})();
|
|||
|
</script><link href="../../../index.css" rel="stylesheet" type="text/css" spa-preserve/><link href="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css" rel="stylesheet" type="text/css" spa-preserve/><link href="https://fonts.googleapis.com/css2?family=IBM Plex Mono&family=Schibsted Grotesk:wght@400;700&family=Source Sans Pro:ital,wght@0,400;0,600;1,400;1,600&display=swap" rel="stylesheet" type="text/css" spa-preserve/><script src="../../../prescript.js" type="application/javascript" spa-preserve></script><script type="application/javascript" spa-preserve>const fetchData = fetch(`../../../static/contentIndex.json`).then(data => data.json())</script></head><body data-slug="Technology/DatabaseSystem/PostgreSQL/基本概念"><div id="quartz-root" class="page"><div id="quartz-body"><div class="left sidebar"><h1 class="page-title "><a href="../../..">📚 X·Eden</a></h1><div class="spacer mobile-only"></div><div class="search "><div id="search-icon"><p>Search</p><div></div><svg tabIndex="0" aria-labelledby="title desc" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7"><title id="title">Search</title><desc id="desc">Search</desc><g class="search-path" fill="none"><path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4"></path><circle cx="8" cy="8" r="7"></circle></g></svg></div><div id="search-container"><div id="search-space"><input autocomplete="off" id="search-bar" name="search" type="text" aria-label="Search for something" placeholder="Search for something"/><div id="results-container"></div></div></div></div><div class="darkmode "><input class="toggle" id="darkmode-toggle" type="checkbox" tabIndex="-1"/><label id="toggle-label-light" for="darkmode-toggle" tabIndex="-1"><svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" version="1.1" id="dayIcon" x="0px" y="0px" viewBox="0 0 35 35" style="enable-background:new 0 0 35 35;" xmlSpace="preserve"><title>Light mode</title><path d="M6,17.5C6,16.672,5.328,16,4.5,16h-3C0.672,16,0,16.672,0,17.5 S0.672,19,1.5,19h3C5.328,19,6,18.328,6,17.5z M7.5,26c-0.414,0-0.789,0.168-1.061,0.439l-2,2C4.168,28.711,4,29.086,4,29.5 C4,30.328,4.671,31,5.5,31c0.414,0,0.789-0.168,1.06-0.44l2-2C8.832,28.289,9,27.914,9,27.5C9,26.672,8.329,26,7.5,26z M17.5,6 C18.329,6,19,5.328,19,4.5v-3C19,0.672,18.329,0,17.5,0S16,0.672,16,1.5v3C16,5.328,16.671,6,17.5,6z M27.5,9 c0.414,0,0.789-0.168,1.06-0.439l2-2C30.832,6.289,31,5.914,31,5.5C31,4.672,30.329,4,29.5,4c-0.414,0-0.789,0.168-1.061,0.44 l-2,2C26.168,6.711,26,7.086,26,7.5C26,8.328,26.671,9,27.5,9z M6.439,8.561C6.711,8.832,7.086,9,7.5,9C8.328,9,9,8.328,9,7.5 c0-0.414-0.168-0.789-0.439-1.061l-2-2C6.289,4.168,5.914,4,5.5,4C4.672,4,4,4.672,4,5.5c0,0.414,0.168,0.789,0.439,1.06 L6.439,8.561z M33.5,16h-3c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5h3c0.828,0,1.5-0.672,1.5-1.5S34.328,16,33.5,16z M28.561,26.439C28.289,26.168,27.914,26,27.5,26c-0.828,0-1.5,0.672-1.5,1.5c0,0.414,0.168,0.789,0.439,1.06l2,2 C28.711,30.832,29.086,31,29.5,31c0.828,0,1.5-0.672,1.5-1.5c0-0.414-0.168-0.789-0.439-1.061L28.561,26.439z M17.5,29 c-0.829,0-1.5,0.672-1.5,1.5v3c0,0.828,0.671,1.5,1.5,1.5s1.5-0.672,1.5-1.5v-3C19,29.672,18.329,29,17.5,29z M17.5,7 C11.71,7,7,11.71,7,17.5S11.71,28,17.5,28S28,23.29,28,17.5S23.29,7,17.5,7z M17.5,25c-4.136,0-7.5-3.364-7.5-7.5 c0-4.136,3.364-7.5,7.5-7.5c4.136,0,7.5,3.364,7.5,7.5C25,21.636,21.636,25,17.5,25z"></path></svg></label><label id="toggle-label-dark" for="darkmode-toggle" tabIndex="-1"><svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" version="1.1" id="nightIcon" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background='new 0 0 100 100'" xmlSpace="preserve"><title>Dark mode</title><path d="M96.76,66.458c-0.853-0.852-2.15-1.064-3.23-0.534c-6.063,2.991-12.858,4.571-19.655,4.571 C62.022,70.495,50.88,65.88,42.5,57.5C29.043,44.043,25.658,23.536,34.076,6.47c0.532-1.08,0.318-2.379-0.534-3.23 c-0.851-0.852-2.15-1.064-3.23-0.534c-4.918,2.427-9.375,5.619-13.246,9.491c-9.447,9.447-14.65,22.008-14.65,35.369 c0,13.
|
|||
|
<pre><code class="mermaid">graph TD;
|
|||
|
A[大型图书馆系统] --> B1[历史分馆]
|
|||
|
A --> B2[科学分馆]
|
|||
|
A --> B3[文学分馆]
|
|||
|
|
|||
|
B1 --> C1[古代历史区]
|
|||
|
B1 --> C2[现代历史区]
|
|||
|
|
|||
|
B2 --> C3[物理学区]
|
|||
|
B2 --> C4[化学区]
|
|||
|
|
|||
|
B3 --> C5[古典文学区]
|
|||
|
B3 --> C6[现代文学区]
|
|||
|
|
|||
|
C1 --> D1[书籍1]
|
|||
|
C1 --> D2[书籍2]
|
|||
|
|
|||
|
C2 --> D3[书籍3]
|
|||
|
C2 --> D4[书籍4]
|
|||
|
|
|||
|
C3 --> D5[书籍5]
|
|||
|
C3 --> D6[书籍6]
|
|||
|
|
|||
|
C4 --> D7[书籍7]
|
|||
|
C4 --> D8[书籍8]
|
|||
|
|
|||
|
C5 --> D9[书籍9]
|
|||
|
C5 --> D10[书籍10]
|
|||
|
|
|||
|
C6 --> D11[书籍11]
|
|||
|
C6 --> D12[书籍12]
|
|||
|
|
|||
|
style A fill:#f9d,stroke:#333,stroke-width:2px;
|
|||
|
style B1 fill:#fc9,stroke:#333,stroke-width:2px;
|
|||
|
style B2 fill:#fc9,stroke:#333,stroke-width:2px;
|
|||
|
style B3 fill:#fc9,stroke:#333,stroke-width:2px;
|
|||
|
style C1 fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style C2 fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style C3 fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style C4 fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style C5 fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style C6 fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style D1 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D2 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D3 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D4 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D5 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D6 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D7 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D8 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D9 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D10 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D11 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style D12 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
</code></pre>
|
|||
|
<p>**PostgreSQL 数据库服务可以被想象成一个大型的图书馆系统,它拥有一套完整的工具和服务来管理和查询存储在其中的数据,就像图书馆中的书籍。**这个系统不仅保证了数据的安全和完整性,还提供了高效的数据访问方式,就如同图书馆的管理员能够妥善管理所有的书籍和资料。</p>
|
|||
|
<p>**在这个图书馆中,我们可以找到多个分馆,这就是所谓的数据库集簇。**每个数据库集簇就像一个分馆,拥有自己的一套书籍和资源,但都受到同一套图书馆系统的管理和维护。在 PostgreSQL 的架构中,一个数据库集簇是由多个数据库组成的,它们共享同一套 PostgreSQL 服务实例和系统资源,形成一个协调一致的系统。</p>
|
|||
|
<p>**每个分馆可以被视为一个单一的实例,它是一个独立运行的 PostgreSQL 服务,管理着一个数据库集簇。**这个实例就像一个独立的图书馆分馆,拥有自己的资源和管理系统,可以为用户提供多样化的服务和资源。</p>
|
|||
|
<p>**分馆中的各个专题区域,就是数据库。**在 PostgreSQL 中,一个数据库就像一个专门的区域,它聚焦于一个特定的主题或应用,存储着一系列相关的数据表和信息。就如同图书馆中有历史、科学或文学等不同的主题区域,每个区域都提供了丰富和多元的资源,满足不同用户的需求和探索。</p>
|
|||
|
<p>通过这样的架构和组织方式,PostgreSQL 成为了一个高度灵活、安全和高效的数据库管理系统,能够满足现代数据管理的多样化需求。</p>
|
|||
|
<h2 id="组成">组成<a aria-hidden="true" tabindex="-1" href="#组成" class="internal"> §</a></h2>
|
|||
|
<h3 id="执行文件">执行文件<a aria-hidden="true" tabindex="-1" href="#执行文件" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>文件名</th><th>描述</th></tr></thead><tbody><tr><td><code>clusterdb</code></td><td>用于重新集群数据库表的工具。</td></tr><tr><td><code>createdb</code></td><td>用于创建新数据库的工具。</td></tr><tr><td><code>createuser</code></td><td>用于创建新数据库用户的工具。</td></tr><tr><td><code>dropdb</code></td><td>用于删除数据库的工具。</td></tr><tr><td><code>dropuser</code></td><td>用于删除数据库用户的工具。</td></tr><tr><td><code>initdb</code></td><td>用于初始化新数据库群集的工具。</td></tr><tr><td><code>oid2name</code></td><td>用于将 OID(对象标识符)转换为名称的工具。</td></tr><tr><td><code>pg_amcheck</code></td><td>用于验证索引的完整性和一致性的工具。</td></tr><tr><td><code>pg_archivecleanup</code></td><td>用于清理归档日志文件的工具,通常与归档日志一起使用。</td></tr><tr><td><code>pg_basebackup</code></td><td>用于创建 PostgreSQL 数据库的基本备份的工具。</td></tr><tr><td><code>pgbench</code></td><td>用于进行性能基准测试的工具。</td></tr><tr><td><code>pg_checksums</code></td><td>用于管理 PostgreSQL 数据目录中的页校验和设置。</td></tr><tr><td><code>pg_config</code></td><td>用于检索 PostgreSQL 安装的配置信息的工具。</td></tr><tr><td><code>pg_controldata</code></td><td>用于检索 PostgreSQL 数据目录中的控制信息的工具。</td></tr><tr><td><code>pg_ctl</code></td><td>用于启动、停止和管理 PostgreSQL 服务器的工具。</td></tr><tr><td><code>pg_dump</code></td><td>用于将 PostgreSQL 数据库导出为 SQL 脚本文件的工具。</td></tr><tr><td><code>pg_dumpall</code></td><td>用于导出所有 PostgreSQL 数据库的工具。</td></tr><tr><td><code>pg_isready</code></td><td>用于检查 PostgreSQL 服务器是否准备好接受连接的工具。</td></tr><tr><td><code>pg_receivewal</code></td><td>用于接收和保存流复制的 WAL(Write-Ahead Logging)数据的工具。</td></tr><tr><td><code>pg_recvlogical</code></td><td>用于接收和保存逻辑复制的数据的工具。</td></tr><tr><td><code>pg_resetwal</code></td><td>用于重置 PostgreSQL 的 WAL 日志文件的工具。</td></tr><tr><td><code>pg_restore</code></td><td>用于从 SQL 脚本文件或自定义归档中恢复 PostgreSQL 数据库的工具。</td></tr><tr><td><code>pg_rewind</code></td><td>用于将一个 PostgreSQL 数据库群集回滚到以前的状态的工具。</td></tr><tr><td><code>pg_test_fsync</code></td><td>用于测试文件同步性能的工具。</td></tr><tr><td><code>pg_test_timing</code></td><td>用于测试系统定时性能的工具。</td></tr><tr><td><code>pg_upgrade</code></td><td>用于升级 PostgreSQL 数据库群集的工具。</td></tr><tr><td><code>pg_verifybackup</code></td><td>用于验证 PostgreSQL 备份的完整性的工具。</td></tr><tr><td><code>pg_waldump</code></td><td>用于解析和显示 WAL(Write-Ahead Logging)文件内容的工具。</td></tr><tr><td><code>postgres</code></td><td>PostgreSQL 服务器主进程的可执行文件。</td></tr><tr><td><code>postmaster</code></td><td>符号链接,指向 PostgreSQL 服务器主进程的可执行文件。</td></tr><tr><td><code>psql</code></td><td>用于与 PostgreSQL 数据库进行交互的命令行客户端工具。</td></tr><tr><td><code>reindexdb</code></td><td>用于重新创建索引的工具。</td></tr><tr><td><code>vacuumdb</code></td><td>用于执行 VACUUM 操作以清理和优化 PostgreSQL 数据库的工具。</td></tr><tr><td><code>vacuumlo</code></td><td>用于管理 PostgreSQL 大对象的工具。</td></tr></tbody></table>
|
|||
|
<h3 id="数据目录">数据目录<a aria-hidden="true" tabindex="-1" href="#数据目录" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>文件/目录名称</th><th>作用</th></tr></thead><tbody><tr><td>base</td><td>存储用户创建的数据库和表的数据文件</td></tr><tr><td>global</td><td>存储系统范围的共享表格定义和数据</td></tr><tr><td>pg_commit_ts</td><td>用于跟踪提交的事务时间戳</td></tr><tr><td>pg_dynshmem</td><td>动态共享内存目录,用于在运行时分配共享内存段</td></tr><tr><td>pg_hba.conf</td><td>客户端身份验证规则配置文件,用于控制客户端连接的权限</td></tr><tr><td>pg_ident.conf</td><td>用于标识客户端连接的规则配置文件</td></tr><tr><td>pg_logical</td><td>用于逻辑复制的相关文件和状态信息</td></tr><tr><td>pg_multixact</td><td>存储多事务共享锁的信息</td></tr><tr><td>pg_notify</td><td>用于实现 <code>NOTIFY</code> 和 <code>LISTEN</code> 功能的通知目录</td></tr><tr><td>pg_replslot</td><td>存储逻辑复制插槽信息的目录</td></tr><tr><td>pg_serial</td><td>存储序列的数据文件</td></tr><tr><td>pg_snapshots</td><td>存储快照信息</td></tr><tr><td>pg_stat</td><td>包含统计信息的目录,用于监视数据库性能</td></tr><tr><td>pg_stat_tmp</td><td>存储临时统计信息的目录</td></tr><tr><td>pg_subtrans</td><td>存储子事务信息</td></tr><tr><td>pg_tblspc</td><td>存储表空间符号链接的目录,每个数据库都有一个符号链接</td></tr><tr><td>pg_twophase</td><td>存储两阶段提交事务信息的目录</td></tr><tr><td>PG_VERSION</td><td>数据库簇的版本信息文件</td></tr><tr><td>pg_wal</td><td>存储 Write-Ahead Logging (WAL) 文件,用于事务恢复和复制</td></tr><tr><td>pg_xact</td><td>存储事务状态文件</td></tr><tr><td>postgresql.auto.conf</td><td>自动生成的配置文件,包含了数据库的自动化配置信息</td></tr><tr><td>postgresql.conf</td><td>数据库的主要配置文件,包含了许多配置选项</td></tr><tr><td><strong>[postmaster.opts]</strong></td><td><strong>包含启动 PostgreSQL 时使用的最后一组选项。</strong></td></tr><tr><td><strong>[postmaster.pid]</strong></td><td><strong>包含运行的 PostgreSQL 主进程的 PID(进程 ID)和其他控制信息,用于防止多个服务器实例在同一数据目录上同时运行。</strong></td></tr></tbody></table>
|
|||
|
<h2 id="设计架构">设计架构<a aria-hidden="true" tabindex="-1" href="#设计架构" class="internal"> §</a></h2>
|
|||
|
<h3 id="架构图">架构图<a aria-hidden="true" tabindex="-1" href="#架构图" class="internal"> §</a></h3>
|
|||
|
<pre><code class="mermaid">graph LR;
|
|||
|
A[PostgreSQL 数据库服务] --> B[数据库集簇];
|
|||
|
B --> C[单一实例];
|
|||
|
C --> D1[数据库 A];
|
|||
|
C --> D2[数据库 B];
|
|||
|
C --> D3[数据库 C];
|
|||
|
D1 --> E1[数据表1];
|
|||
|
D1 --> E2[数据表2];
|
|||
|
D1 --> F1[视图];
|
|||
|
D1 --> F2[函数];
|
|||
|
D1 --> F3[触发器];
|
|||
|
E1 --> G1[列];
|
|||
|
E1 --> G2[索引];
|
|||
|
E1 --> G3[主键];
|
|||
|
E1 --> G4[外键];
|
|||
|
E1 --> G9[约束];
|
|||
|
E2 --> G5[列];
|
|||
|
E2 --> G6[索引];
|
|||
|
E2 --> G7[主键];
|
|||
|
E2 --> G8[外键];
|
|||
|
E2 --> G10[约束];
|
|||
|
A --> H1[事务和并发控制];
|
|||
|
A --> H2[备份和恢复];
|
|||
|
A --> H3[安全性和权限管理];
|
|||
|
A --> H4[复制和高可用性];
|
|||
|
A --> H5[扩展性和插件];
|
|||
|
A --> H6[连接管理];
|
|||
|
A --> H7[监听和通知];
|
|||
|
|
|||
|
A --> I[进程管理器];
|
|||
|
A --> J[SQL 解析器];
|
|||
|
A --> K[查询优化器];
|
|||
|
A --> L[查询执行器];
|
|||
|
|
|||
|
I --> M[后台进程];
|
|||
|
I --> N[自动清理进程];
|
|||
|
I --> O[后台工作进程];
|
|||
|
|
|||
|
L --> P[存储管理器];
|
|||
|
P --> Q[缓冲区管理];
|
|||
|
P --> R[磁盘空间管理];
|
|||
|
P --> S[事务管理];
|
|||
|
P --> X[日志管理];
|
|||
|
|
|||
|
Q --> T[共享缓冲区];
|
|||
|
|
|||
|
S --> V[事务日志];
|
|||
|
S --> W[多版本并发控制 MVCC];
|
|||
|
S --> U[WAL 预写日志];
|
|||
|
|
|||
|
H1 --> Y[锁管理];
|
|||
|
H2 --> Z1[物理备份];
|
|||
|
H2 --> Z2[逻辑备份];
|
|||
|
H3 --> Z3[角色和权限管理];
|
|||
|
H3 --> Z4[加密和认证];
|
|||
|
H4 --> Z6[主从复制];
|
|||
|
H4 --> Z7[同步复制];
|
|||
|
H5 --> Z8[新数据类型];
|
|||
|
H5 --> Z9[新函数];
|
|||
|
H6 --> Z10[客户端连接];
|
|||
|
H7 --> Z11[LISTEN];
|
|||
|
H7 --> Z12[NOTIFY];
|
|||
|
|
|||
|
K --> Z5[统计信息];
|
|||
|
|
|||
|
L --> Z13[顺序扫描];
|
|||
|
L --> Z14[索引扫描];
|
|||
|
L --> Z15[哈希连接];
|
|||
|
|
|||
|
style A fill:#f9d,stroke:#333,stroke-width:2px;
|
|||
|
style B fill:#fc9,stroke:#333,stroke-width:2px;
|
|||
|
style C fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style D1 fill:#9fc,stroke:#333,stroke-width:2px;
|
|||
|
style D2 fill:#9fc,stroke:#333,stroke-width:2px;
|
|||
|
style D3 fill:#9fc,stroke:#333,stroke-width:2px;
|
|||
|
style E1 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style E2 fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style F1 fill:#ccf,stroke:#333,stroke-width:2px;
|
|||
|
style F2 fill:#ccf,stroke:#333,stroke-width:2px;
|
|||
|
style F3 fill:#ccf,stroke:#333,stroke-width:2px;
|
|||
|
style G1 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G2 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G3 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G4 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G5 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G6 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G7 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G8 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G9 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style G10 fill:#fcc,stroke:#333,stroke-width:2px;
|
|||
|
style H1 fill:#ccc,stroke:#333,stroke-width:2px;
|
|||
|
style H2 fill:#ccc,stroke:#333,stroke-width:2px;
|
|||
|
style H3 fill:#ccc,stroke:#333,stroke-width:2px;
|
|||
|
style H4 fill:#ccc,stroke:#333,stroke-width:2px;
|
|||
|
style H5 fill:#ccc,stroke:#333,stroke-width:2px;
|
|||
|
style H6 fill:#ccc,stroke:#333,stroke-width:2px;
|
|||
|
style H7 fill:#ccc,stroke:#333,stroke-width:2px;
|
|||
|
|
|||
|
</code></pre>
|
|||
|
<h3 id="进程结构">进程结构<a aria-hidden="true" tabindex="-1" href="#进程结构" class="internal"> §</a></h3>
|
|||
|
<pre><code class="mermaid">graph LR
|
|||
|
|
|||
|
A[客户端] --> B[后端进程/Backend Process]
|
|||
|
B --> C[共享缓冲区/Shared Buffers]
|
|||
|
B --> D[事务日志/WAL Writer]
|
|||
|
B --> E[查询执行器/Query Executor]
|
|||
|
B --> L[日志管理器/Log Manager]
|
|||
|
B --> M[缓冲管理器/Buffer Manager]
|
|||
|
B --> N[锁管理器/Lock Manager]
|
|||
|
B --> O[进程间通信/IPC]
|
|||
|
|
|||
|
C --> D[事务日志/WAL Writer]
|
|||
|
E --> C[共享缓冲区/Shared Buffers]
|
|||
|
D --> J[归档进程/Archiver]
|
|||
|
|
|||
|
F[后台进程/Background Processes] --> C
|
|||
|
F --> D
|
|||
|
F --> G[统计信息收集器/Stats Collector]
|
|||
|
F --> H[自动清理进程/Autovacuum Worker]
|
|||
|
F --> I[检查点进程/Checkpointer]
|
|||
|
F --> J
|
|||
|
F --> K[后台工作进程/Background Worker]
|
|||
|
F --> P[WAL Receiver]
|
|||
|
|
|||
|
I --> C[共享缓冲区/Shared Buffers]
|
|||
|
|
|||
|
style A fill:#f9d,stroke:#333,stroke-width:2px;
|
|||
|
style B fill:#fc9,stroke:#333,stroke-width:2px;
|
|||
|
style C fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style D fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style E fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style F fill:#9fc,stroke:#333,stroke-width:2px;
|
|||
|
style G fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style H fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style I fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style J fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style K fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style L fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style M fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style N fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style O fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
style P fill:#c9f,stroke:#333,stroke-width:2px;
|
|||
|
</code></pre>
|
|||
|
<ul>
|
|||
|
<li><strong>客户端</strong>: 这是用户与 PostgreSQL 数据库交互的入口点。客户端可以是任何支持 PostgreSQL 的应用程序或工具,如 psql、PgAdmin 等。</li>
|
|||
|
<li><strong>后端进程/Backend Process</strong>: 当客户端发起连接请求时,PostgreSQL 会为每个连接创建一个后端进程。这个进程负责处理客户端的所有请求,包括查询执行、事务管理等。</li>
|
|||
|
<li><strong>共享缓冲区/Shared Buffers</strong>: 这是 PostgreSQL 的内存缓存,用于存储表数据、索引、系统目录等。后端进程和后台进程都可以访问这个缓冲区。</li>
|
|||
|
<li><strong>事务日志/WAL Writer</strong>: WAL (Write-Ahead Logging) 是 PostgreSQL 的一种持久化机制。在数据被写入磁盘之前,所有的修改都会先被记录在 WAL 中。这确保了在系统崩溃的情况下数据的完整性和持久性。</li>
|
|||
|
<li><strong>查询执行器/Query Executor</strong>: 负责解析、优化和执行 SQL 查询。</li>
|
|||
|
<li><strong>后台进程/Background Processes</strong>: 这是一组进程,负责各种后台任务,如清理、统计信息收集、日志归档等。</li>
|
|||
|
<li><strong>统计信息收集器/Stats Collector</strong>: 收集数据库的使用统计信息,如查询执行次数、表的访问频率等。</li>
|
|||
|
<li><strong>自动清理进程/Autovacuum Worker</strong>: 负责清理旧的数据和空间回收。</li>
|
|||
|
<li><strong>检查点进程/Checkpointer</strong>: 定期将共享缓冲区中的数据写入磁盘,并创建检查点。</li>
|
|||
|
<li><strong>归档进程/Archiver</strong>: 负责将 WAL 日志文件归档到一个指定的位置,以便于备份和恢复。</li>
|
|||
|
<li><strong>后台工作进程/Background Worker</strong>: 可以执行各种自定义的后台任务。</li>
|
|||
|
<li><strong>日志管理器/Log Manager , 缓冲管理器/Buffer Manager , 锁管理器/Lock Manager , 进程间通信/IPC</strong>: 这些都是 PostgreSQL 内部的核心组件,负责日志记录、缓冲管理、锁定资源和进程间的通信。</li>
|
|||
|
<li><strong>WAL Receiver</strong>: 在复制环境中,WAL Receiver 负责从主服务器接收 WAL 记录。</li>
|
|||
|
</ul>
|
|||
|
<h3 id="内存结构">内存结构<a aria-hidden="true" tabindex="-1" href="#内存结构" class="internal"> §</a></h3>
|
|||
|
<pre><code class="mermaid">graph LR
|
|||
|
|
|||
|
A[PostgreSQL 内存结构]
|
|||
|
A --> B[共享缓冲区/Shared Buffers]
|
|||
|
A --> C[工作内存/Work Mem]
|
|||
|
A --> D[维护工作内存/Maintenance Work Mem]
|
|||
|
A --> E[WAL缓冲区/WAL Buffers]
|
|||
|
A --> F[本地缓冲区/Local Buffers]
|
|||
|
A --> G[消息层/Message Layer]
|
|||
|
A --> H[CLOG缓冲区/CLOG Buffers]
|
|||
|
A --> I[TOAST缓冲区/TOAST Buffers]
|
|||
|
|
|||
|
style A fill:#f9d,stroke:#333,stroke-width:2px;
|
|||
|
style B fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style C fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style D fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style E fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style F fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style G fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style H fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
style I fill:#9cf,stroke:#333,stroke-width:2px;
|
|||
|
</code></pre>
|
|||
|
<ul>
|
|||
|
<li><strong>PostgreSQL 内存结构</strong>: 这是 PostgreSQL 数据库的总体内存结构,它包含了多个专门的缓冲区和内存区域,用于不同的任务和操作。</li>
|
|||
|
<li><strong>共享缓冲区/Shared Buffers</strong>: 这是 PostgreSQL 的主要缓存区,用于存储表数据、索引和系统目录。它是所有后端进程和后台进程共享的,用于减少磁盘 I/O。</li>
|
|||
|
<li><strong>工作内存/Work Mem</strong>: 用于存储排序和哈希操作的中间结果。每个后端进程都有自己的工作内存。</li>
|
|||
|
<li><strong>维护工作内存/Maintenance Work Mem</strong>: 用于存储维护任务(如 VACUUM、CREATE INDEX)的中间结果。这通常比普通的工作内存大。</li>
|
|||
|
<li><strong>WAL 缓冲区/WAL Buffers</strong>: 用于存储即将写入 WAL(Write-Ahead Logging)的日志记录。这确保了在数据被写入磁盘之前,所有的修改都会先被记录在 WAL 中。</li>
|
|||
|
<li><strong>本地缓冲区/Local Buffers</strong>: 用于存储临时表的数据。与共享缓冲区不同,本地缓冲区是每个后端进程私有的。</li>
|
|||
|
<li><strong>消息层/Message Layer</strong>: 负责处理后端进程之间的消息传递,如锁通知和进程间通信。</li>
|
|||
|
<li><strong>CLOG 缓冲区/CLOG Buffers</strong>: CLOG (Commit Log) 用于存储事务的提交状态。每个事务都有一个对应的 CLOG 记录,指示它是已提交、未提交还是中止。</li>
|
|||
|
<li><strong>TOAST 缓冲区/TOAST Buffers</strong>: TOAST (The Oversized-Attribute Storage Technique) 是 PostgreSQL 用于存储大型数据的机制。当一个数据项太大而不能直接存储在常规的数据页中时,它会被“toast”到一个特殊的 TOAST 表中,并在原表中保留一个指针。TOAST 缓冲区用于缓存这些大型数据项。</li>
|
|||
|
</ul>
|
|||
|
<h3 id="逻辑存储结构">逻辑存储结构<a aria-hidden="true" tabindex="-1" href="#逻辑存储结构" class="internal"> §</a></h3>
|
|||
|
<pre><code class="mermaid">graph LR
|
|||
|
|
|||
|
A[数据库集群/Cluster]
|
|||
|
A --> B[全局系统目录/pg_global]
|
|||
|
A --> C[数据库/Database 1]
|
|||
|
A --> D[数据库/Database 2]
|
|||
|
A --> E[...]
|
|||
|
A --> F[数据库/Database N]
|
|||
|
A --> S[表空间/Tablespace 1]
|
|||
|
A --> T[表空间/Tablespace 2]
|
|||
|
A --> U[...]
|
|||
|
A --> V[表空间/Tablespace N]
|
|||
|
|
|||
|
B --> G[全局表/Global Tables]
|
|||
|
B --> H[全局系统目录/Global System Catalogs]
|
|||
|
|
|||
|
C --> M[系统目录/System Catalogs]
|
|||
|
C --> N[用户表/User Tables]
|
|||
|
C --> O[索引/Indexes]
|
|||
|
C --> P[视图/Views]
|
|||
|
C --> Q[序列/Sequences]
|
|||
|
C --> R[其他对象/Other Objects]
|
|||
|
C --> W[扩展/Extensions]
|
|||
|
|
|||
|
</code></pre>
|
|||
|
<h3 id="物理存储结构">物理存储结构<a aria-hidden="true" tabindex="-1" href="#物理存储结构" class="internal"> §</a></h3>
|
|||
|
<pre><code class="mermaid">graph TD
|
|||
|
A[数据库 Database]
|
|||
|
B1[表空间 Tablespace 1]
|
|||
|
B2[表空间 Tablespace 2]
|
|||
|
C1[关系文件 Relation File 1]
|
|||
|
C2[关系文件 Relation File 2]
|
|||
|
D[数据文件 Data File]
|
|||
|
E[索引文件 Index File]
|
|||
|
F[事务日志 WAL]
|
|||
|
G[统计信息 Statistics]
|
|||
|
H[配置文件 Config Files]
|
|||
|
I[备份文件 Backup Files]
|
|||
|
|
|||
|
A --> B1
|
|||
|
A --> B2
|
|||
|
B1 --> C1
|
|||
|
B2 --> C2
|
|||
|
C1 --> D
|
|||
|
C1 --> E
|
|||
|
C2 --> D
|
|||
|
C2 --> E
|
|||
|
A --> F
|
|||
|
A --> G
|
|||
|
A --> H
|
|||
|
A --> I
|
|||
|
</code></pre>
|
|||
|
<h3 id="堆表文件内部结构">堆表文件内部结构<a aria-hidden="true" tabindex="-1" href="#堆表文件内部结构" class="internal"> §</a></h3>
|
|||
|
<pre><code class="mermaid">graph TD
|
|||
|
A[页面 Page]
|
|||
|
B[页面头部 Page Header]
|
|||
|
C[项目指针数组 Item Pointer Array]
|
|||
|
D[元组1 Tuple 1]
|
|||
|
E[元组2 Tuple 2]
|
|||
|
F[元组N Tuple N]
|
|||
|
G[空闲空间图 Free Space Map]
|
|||
|
H[可见性图 Visibility Map]
|
|||
|
I[多版本并发控制 MVCC]
|
|||
|
J[仅堆元组 HOT]
|
|||
|
|
|||
|
A --> B
|
|||
|
A --> C
|
|||
|
C --> D
|
|||
|
C --> E
|
|||
|
C --> F
|
|||
|
A --> G
|
|||
|
A --> H
|
|||
|
D --> I
|
|||
|
E --> I
|
|||
|
F --> I
|
|||
|
D --> J
|
|||
|
E --> J
|
|||
|
F --> J
|
|||
|
</code></pre>
|
|||
|
<h2 id="服务模式">服务模式<a aria-hidden="true" tabindex="-1" href="#服务模式" class="internal"> §</a></h2>
|
|||
|
<pre><code class="mermaid">graph TD
|
|||
|
A[PostgreSQL 服务模式]
|
|||
|
B[单用户模式]
|
|||
|
C[多用户模式]
|
|||
|
D[主-从复制模式]
|
|||
|
E[集群模式]
|
|||
|
F[主数据库]
|
|||
|
G[从数据库1]
|
|||
|
H[从数据库2]
|
|||
|
I[服务实例1]
|
|||
|
J[服务实例2]
|
|||
|
K[服务实例3]
|
|||
|
|
|||
|
A --> B
|
|||
|
A --> C
|
|||
|
A --> D
|
|||
|
A --> E
|
|||
|
|
|||
|
D --> F
|
|||
|
F --> G[同步数据]
|
|||
|
F --> H[同步数据]
|
|||
|
|
|||
|
E --> I
|
|||
|
E --> J
|
|||
|
E --> K
|
|||
|
|
|||
|
style A fill:#f9d,stroke:#333,stroke-width:2px
|
|||
|
style B fill:#eef,stroke:#333,stroke-width:2px
|
|||
|
style C fill:#eef,stroke:#333,stroke-width:2px
|
|||
|
style D fill:#eef,stroke:#333,stroke-width:2px
|
|||
|
style E fill:#eef,stroke:#333,stroke-width:2px
|
|||
|
style F fill:#ddd,stroke:#333,stroke-width:2px
|
|||
|
style G fill:#ddd,stroke:#333,stroke-width:2px
|
|||
|
style H fill:#ddd,stroke:#333,stroke-width:2px
|
|||
|
style I fill:#ddd,stroke:#333,stroke-width:2px
|
|||
|
style J fill:#ddd,stroke:#333,stroke-width:2px
|
|||
|
style K fill:#ddd,stroke:#333,stroke-width:2px
|
|||
|
</code></pre>
|
|||
|
<h3 id="单用户模式">单用户模式<a aria-hidden="true" tabindex="-1" href="#单用户模式" class="internal"> §</a></h3>
|
|||
|
<p>在单用户模式下,PostgreSQL 服务只允许一个用户(或一个应用)同时访问和操作数据库。这就像一个图书馆在特定时间只对一名读者开放,以便他/她可以独自浏览和使用图书馆的所有资源,而不会受到其他人的干扰。这种模式**通常用于数据库维护和故障排除。**在这种模式下,由于没有并发访问,管理员可以更容易地进行数据库的维护工作,如备份、恢复、重建索引等。</p>
|
|||
|
<h3 id="多用户模式">多用户模式<a aria-hidden="true" tabindex="-1" href="#多用户模式" class="internal"> §</a></h3>
|
|||
|
<p><strong>多用户模式是 PostgreSQL 的常规运行模式</strong>,它允许多个用户(或多个应用)同时访问和操作数据库。这就像一个图书馆在正常营业时间对所有读者开放,每个人都可以自由地浏览书籍和使用资源,同时图书馆的管理员会确保所有的操作都是有序和高效的。在这种模式下,数据库服务器必须处理并发访问,确保数据的完整性和一致性,并提供事务管理功能。</p>
|
|||
|
<h3 id="主---从复制模式">主 - 从复制模式<a aria-hidden="true" tabindex="-1" href="#主---从复制模式" class="internal"> §</a></h3>
|
|||
|
<p>在主 - 从复制模式下,有一个主数据库(主图书馆)和一个或多个从数据库(分支图书馆)。**主数据库负责处理所有的写操作(如添加新书籍),而从数据库则是主数据库的只读副本,用于处理读操作(如查询书籍)。**从数据库会定期从主数据库同步数据,以保证数据的一致性。这样可以提高系统的读取性能和可用性。此外,这种模式还为数据备份和灾难恢复提供了额外的保障,因为从数据库可以作为备份数据源。</p>
|
|||
|
<h3 id="集群模式">集群模式<a aria-hidden="true" tabindex="-1" href="#集群模式" class="internal"> §</a></h3>
|
|||
|
<p>**在集群模式下,多个 PostgreSQL 服务实例协同工作,共同提供数据库服务。**这就像一个图书馆网络,其中每个图书馆都可以提供完整的服务,并通过协同工作来提供更高效和更可靠的服务。这种模式可以提高系统的性能和可用性,同时也提供了更高的数据安全性。集群中的每个实例都可以处理读写请求,而数据的分布和复制是由集群管理软件自动处理的。这种模式通常用于大型、高并发的应用场景,需要高可用性和故障切换能力。</p></article></div><div class="right sidebar"><div class="graph "><h3>Graph View</h3><div class="graph-outer"><div id="graph-container" data-cfg="{"drag":true,"zoom":true,"depth":1,"scale":1.1,"repelForce":0.5,"centerForce":0.3,"linkDistance":30,"fontSize":0.6,"opacityScale":1,"showTags":true,"removeTags":[]}"></div><svg version="1.1" id="global-graph-icon" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 55 55" fill="currentColor" xmlSpace="preserve"><path d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
|
|||
|
s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
|
|||
|
c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
|
|||
|
C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
|
|||
|
c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91
|
|||
|
v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4
|
|||
|
s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665
|
|||
|
C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2
|
|||
|
S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
|
|||
|
s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
|
|||
|
s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"></path></svg></div><div id="global-graph-outer"><div id="global-graph-container" data-cfg="{"drag":true,"zoom":true,"depth":-1,"scale":0.9,"repelForce":0.5,"centerForce":0.3,"linkDistance":30,"fontSize":0.6,"opacityScale":1,"showTags":true,"removeTags":[]}"></div></div></div><div class="toc desktop-only"><button type="button" id="toc" class><h3>Table of Contents</h3><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="fold"><polyline points="6 9 12 15 18 9"></polyline></svg></button><div id="toc-content"><ul class="overflow"><li class="depth-0"><a href="#引言" data-for="引言">引言</a></li><li class="depth-0"><a href="#组成" data-for="组成">组成</a></li><li class="depth-1"><a href="#执行文件" data-for="执行文件">执行文件</a></li><li class="depth-1"><a href="#数据目录" data-for="数据目录">数据目录</a></li><li class="depth-0"><a href="#设计架构" data-for="设计架构">设计架构</a></li><li class="depth-1"><a href="#架构图" data-for="架构图">架构图</a></li><li class="depth-1"><a href="#进程结构" data-for="进程结构">进程结构</a></li><li class="depth-1"><a href="#内存结构" data-for="内存结构">内存结构</a></li><li class="depth-1"><a href="#逻辑存储结构" data-for="逻辑存储结构">逻辑存储结构</a></li><li class="depth-1"><a href="#物理存储结构" data-for="物理存储结构">物理存储结构</a></li><li class="depth-1"><a href="#堆表文件内部结构" data-for="堆表文件内部结构">堆表文件内部结构</a></li><li class="depth-0"><a href="#服务模式" data-for="服务模式">服务模式</a></li><li class="depth-1"><a href="#单用户模式" data-for="单用户模式">单用户模式</a></li><li class="depth-1"><a href="#多用户模式" data-for="多用户模式">多用户模式</a></li><li class="depth-1"><a href="#主---从复制模式" data-for="主---从复制模式">主 - 从复制模式</a></li><li class="depth-1"><a href="#集群模式" data-for="集群模式">集群模式</a></li></ul></div></div><div class="backlinks "><h3>Backlinks</h3><ul class="overflow"><li>No backlinks found</li></ul></div><div class="explorer mobile-only"><button type="button" id="explorer" data-behavior="collapse" data-collapsed="collapsed" data-savestate="true" data-tree="[{"path":"Journal","collapsed":true},{"path":"Journal/2024","collapsed":true},{"path":"Journal/2024/W33","collapsed":true},{"path":"Obsidian","collapsed":true},{"path":"Obsidian/Templates","collapsed":true},{"path":"Personal","collapsed":true},{"path":"Personal/Blog","collapsed":true},{"path":"Personal/Blog/2018","collapsed":true},{"path":"Personal/Blog/2020","collapsed":true},{"path":"Personal/Blog/2021","collapsed":true},{"path":"Personal/Blog/2022","collapsed":true},{"path":"Personal/Blog/2023","collapsed":true},{"path":"Personal/Blog/2024","collapsed":true},{"path":"Personal/Book","collapsed":true},{"path":"Personal/Book/个人成长","collapsed":true},{"path":"Personal/Book/医学健康","collapsed":true},{"path":"Personal/Book/历史","collapsed":true},{"path":"Personal/Book/哲学宗教","collapsed":true},{"path":"Personal/Book/心理","collapsed"
|
|||
|
function toggleCallout() {
|
|||
|
const outerBlock = this.parentElement;
|
|||
|
outerBlock.classList.toggle(`is-collapsed`);
|
|||
|
const collapsed = outerBlock.classList.contains(`is-collapsed`);
|
|||
|
const height = collapsed ? this.scrollHeight : outerBlock.scrollHeight;
|
|||
|
outerBlock.style.maxHeight = height + `px`;
|
|||
|
let current = outerBlock;
|
|||
|
let parent = outerBlock.parentElement;
|
|||
|
while (parent) {
|
|||
|
if (!parent.classList.contains(`callout`)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
const collapsed2 = parent.classList.contains(`is-collapsed`);
|
|||
|
const height2 = collapsed2 ? parent.scrollHeight : parent.scrollHeight + current.scrollHeight;
|
|||
|
parent.style.maxHeight = height2 + `px`;
|
|||
|
current = parent;
|
|||
|
parent = parent.parentElement;
|
|||
|
}
|
|||
|
}
|
|||
|
function setupCallout() {
|
|||
|
const collapsible = document.getElementsByClassName(
|
|||
|
`callout is-collapsible`
|
|||
|
);
|
|||
|
for (const div of collapsible) {
|
|||
|
const title = div.firstElementChild;
|
|||
|
if (title) {
|
|||
|
title.removeEventListener(`click`, toggleCallout);
|
|||
|
title.addEventListener(`click`, toggleCallout);
|
|||
|
const collapsed = div.classList.contains(`is-collapsed`);
|
|||
|
const height = collapsed ? title.scrollHeight : div.scrollHeight;
|
|||
|
div.style.maxHeight = height + `px`;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
document.addEventListener(`nav`, setupCallout);
|
|||
|
window.addEventListener(`resize`, setupCallout);
|
|||
|
</script><script type="module">
|
|||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
|||
|
const darkMode = document.documentElement.getAttribute('saved-theme') === 'dark'
|
|||
|
mermaid.initialize({
|
|||
|
startOnLoad: false,
|
|||
|
securityLevel: 'loose',
|
|||
|
theme: darkMode ? 'dark' : 'default'
|
|||
|
});
|
|||
|
document.addEventListener('nav', async () => {
|
|||
|
await mermaid.run({
|
|||
|
querySelector: '.mermaid'
|
|||
|
})
|
|||
|
});
|
|||
|
</script><script src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/contrib/copy-tex.min.js" type="application/javascript"></script><script src="../../../postscript.js" type="module"></script></html>
|