<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] # <span style="font-size:15px">**邏輯結構** </span> ![](https://img.kancloud.cn/e1/45/e1450f468cba060b8110c13f422248a5_2766x896.png) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;如圖,postgresql邏輯結構層級劃分:databse cluster --> database --> schema --> table(index) --> segments --> pages --> tuples。 * segment:數據文件會被切割成多個segmemts, 默認1G; * page(block):每個segment內部都會被劃分成多個pages,默認8k,page是IO操作的最小單位; * tuple:每行記錄叫tuple,每個tuple對應一個tid(tuple identififiers); * relation:table、index、sequence, view, function等叫relation; * oid:object identififiers (OIDs),每個relation都是通過對應的oid進行管理; * relfifilenode:一般情況 relfifilenode = oid,用于管理具體的數據文件; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PostgreSQL 中的所有數據庫對象都由各自的對象標識符 (OID) 內部管理,它們是無符號的 4 字節整數。 根據對象的類型,數據庫對象和相應 OID 之間的關系存儲在適當的系統目錄中。 例如,數據庫和堆表的OID分別存儲在pg_database和pg_class中。 ``` // 查看database cluster,不同的db之間的數據是不能訪問的 postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | template0 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres test | postgres | UTF8 | zh_CN.UTF-8 | zh_CN.UTF-8 | (4 rows) // 查看schemas,同一個db下的不同schema的數據是可以訪問的 postgres=# \dn List of schemas Name | Owner ----------+---------- myschema | postgres public | postgres (2 rows) postgres=# \d List of relations Schema | Name | Type | Owner --------+--------------------+----------+---------- public | alerts | table | postgres public | alerts_id_seq | sequence | postgres public | goods | table | postgres public | pg_stat_statements | view | postgres public | products | table | postgres public | test | table | postgres (6 rows) // 每個tuple都有一個tid,表示第0個page的第1行 postgres=\# select ctid, name, age from t001; ctid | name | age -------+-----------+----- (0,1) | damon0668 | 1 (0,2) | damon0669 | 2 // 查看database的oid postgres=# select oid, datname from pg_database where datname = 'test'; oid | datname -------+--------- 16411 | test (1 row) // 查看table的oid和relfilenode,一般情況 oid = relfilenode postgres=# select oid, relfilenode, relname from pg_class where relname = 'test'; oid | relfilenode | relname -------+-------------+--------- 16384 | 16550 | test (1 row) // truncate之后,oid不變,relfilenode變了,此時oid != relfilenode postgres=# TRUNCATE test; TRUNCATE TABLE postgres=# select oid, relfilenode, relname from pg_class where relname = 'test'; oid | relfilenode | relname -------+-------------+--------- 16384 | 16720 | test (1 row) ``` # <span style="font-size:15px">**物理結構** </span> ``` [root@izwz91quxhnlkan8kjak5hz postgres]# tree -L 2 . ├── base │?? ├── 1 // 數據庫oid │?? │?? ├── 112 // 數據文件,對應表的relfilenode │?? │?? ├── 113 │?? │?? ├── 113.1 // 被截取的數據文件段 │?? │?? ├── 1247 │?? │?? ├── 1247_fsm // free space map,記錄每一個page的空閑空間 │?? │?? ├── 1247_vm // 可見性映射表,顯示占用的tuple,掃描的時候會跳過這些tuple │?? ├── 13579 │?? ├── 13580 │?? ├── 16411 │?? └── pgsql_tmp // 臨時文件存儲目錄 ├── global │?? ├── 1213 │?? ├── 1213_fsm │?? ├── 1213_vm │?? ├── 1214 │?? ├── 1214_fsm │?? ├── 1214_vm │?? ├── 1232 │?? ├── pg_control // 用于存儲全局控制信息 │?? ├── pg_filenode.map // pg_class里relfilenode為0的系統表,OID與文件的硬編碼映射 │?? └── pg_internal.init // 系統表的cache文件,用于加快讀取。默認不存在,查詢系統表后自動產生 ├── pg_commit_ts // 該目錄包含已提交事務的時間 ├── pg_dynshmem // 該目錄包含動態共享內存子系統使用的文件 ├── pg_hba.conf // 客戶端認證控制文件 ├── pg_ident.conf // 用來配置哪些操作系統用戶可以映射為哪個數據庫用戶 ├── pg_logical // 邏輯復制的狀態數據的目錄 │?? ├── mappings │?? ├── replorigin_checkpoint │?? └── snapshots ├── pg_multixact // 存儲多事務狀態數據的子目錄(用戶共享的行鎖) │?? ├── members │?? └── offsets ├── pg_notify // 包含LISTEN/NOTIFY狀態數據的目錄 ├── pg_replslot // 該目錄包含了復制槽的數據 ├── pg_serial // 已提交的可序列化事務信息的目錄 ├── pg_snapshots // 儲存導出的快照 ├── pg_stat // 統計信息的存儲目錄 ├── pg_stat_tmp // 統計信息的存儲臨時目錄 │?? ├── db_0.stat │?? ├── db_13580.stat │?? ├── db_16411.stat │?? ├── global.stat │?? └── pgss_query_texts.stat ├── pg_subtrans // 存儲子事務狀態數據的目錄 │?? └── 0000 ├── pg_tblspc // 存儲表空間的符號鏈接 ├── pg_twophase // 用于存儲預備事務狀態文件的目 ├── PG_VERSION ├── pg_wal // 保存預寫日志的目錄 │?? ├── 000000010000000400000050 ... ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看