我正在使用 postgresql頁面檢查器,我想知道,在哪里可以找到有關其函式輸出的更詳細檔案(輸入也很好)。我只對 b-tree 函式感興趣。
檔案說例如:
bt_page_stats 回傳有關 B 樹索引的單個頁面的摘要資訊。例如:
test=# SELECT * FROM bt_page_stats('pg_cast_oid_index', 1);
-[ RECORD 1 ]- -----
blkno | 1
type | l
live_items | 224
dead_items | 0
avg_item_size | 16
page_size | 8192
free_size | 3668
btpo_prev | 0
btpo_next | 0
btpo_level | 0
btpo_flags | 3
在這里,我想知道這些結果的實際含義 - 什么是型別、dead_items 等等。我在哪里可以找到它?
uj5u.com熱心網友回復:
要了解這些值,您必須了解 B 樹索引的樹結構。
從某種程度的細節來看,記錄在源中,在本例中為src/include/access/nbtree.h:
/*
* BTPageOpaqueData -- At the end of every page, we store a pointer
* to both siblings in the tree. This is used to do forward/backward
* index scans. The next-page link is also critical for recovery when
* a search has navigated to the wrong page due to concurrent page splits
* or deletions; see src/backend/access/nbtree/README for more info.
*
* In addition, we store the page's btree level (counting upwards from
* zero at a leaf page) as well as some flag bits indicating the page type
* and status. If the page is deleted, a BTDeletedPageData struct is stored
* in the page's tuple area, while a standard BTPageOpaqueData struct is
* stored in the page special area.
*
* We also store a "vacuum cycle ID". When a page is split while VACUUM is
* processing the index, a nonzero value associated with the VACUUM run is
* stored into both halves of the split page. (If VACUUM is not running,
* both pages receive zero cycleids.) This allows VACUUM to detect whether
* a page was split since it started, with a small probability of false match
* if the page was last split some exact multiple of MAX_BT_CYCLE_ID VACUUMs
* ago. Also, during a split, the BTP_SPLIT_END flag is cleared in the left
* (original) page, and set in the right page, but only if the next page
* to its right has a different cycleid.
*
* NOTE: the BTP_LEAF flag bit is redundant since level==0 could be tested
* instead.
*
* NOTE: the btpo_level field used to be a union type in order to allow
* deleted pages to store a 32-bit safexid in the same field. We now store
* 64-bit/full safexid values using BTDeletedPageData instead.
*/
typedef struct BTPageOpaqueData
{
BlockNumber btpo_prev; /* left sibling, or P_NONE if leftmost */
BlockNumber btpo_next; /* right sibling, or P_NONE if rightmost */
uint32 btpo_level; /* tree level --- zero for leaf pages */
uint16 btpo_flags; /* flag bits, see below */
BTCycleId btpo_cycleid; /* vacuum cycle ID of latest split */
} BTPageOpaqueData;
其他值是:
blkno: 8kB 塊數type:頁面的型別(l對于“葉”、i“內部”、r“根”、e“忽略”、d“已洗掉的葉子”、D“已洗掉的內部”)live_items:實時索引條目的數量dead_items:被殺死的索引條目數avg_item_size: 索引元組的平均大小page_size:頁面大小(始終為 8kB)free_size: 頁面中的可用空間
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/334432.html
標籤:PostgreSQL
