本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
STV_BLOCKLIST
STV_BLOCKLIST 包含資料庫中各個分割、資料表或欄位所使用的 1 MB 磁碟區塊數。
使用彙總查詢與 STV_BLOCKLIST (如下範例所示) 以判斷每個資料庫、資料表、分割或欄位所配置的 1 MB 磁碟區塊數。您也可以使用 STV_PARTITIONS 來檢視磁碟使用率的摘要資訊。
只有超級使用者可以看到 STV_BLOCKLIST。如需詳細資訊,請參閱系統資料表和檢視中資料的可見性。
注意
STV_BLOCKLIST 只會記錄佈建叢集或無伺服器命名空間所擁有的區塊。如果資料庫包含從資料共用生產者共用的區塊,這些區塊不會包含在 STV_BLOCKLIST 中。如需資料共用的詳細資訊,請前往 Amazon Redshift 中的資料共用。
資料表欄
欄名稱 | 資料類型 | 描述 |
---|---|---|
分割 | integer | 節點分割。 |
col | integer | 欄位的以零為起始的索引。您建立的每個資料表皆附加三個隱藏欄位:INSERT_XID、DELETE_XID 及 ROW_ID (OID)。包含 3 個使用者定義欄位的資料表包含 6 個實際欄位,使用者定義的欄位的內部編號為 0、1 及 2。在此範例中,INSERT_XID、DELETE_XID 及 ROW_ID 欄位的編號分別為 3、4 及 5。 |
tbl | integer | 資料庫資料表的資料表 ID。 |
blocknum | integer | 資料區塊的 ID。 |
num_values | integer | 區塊所包含的值的數量。 |
extended_limits | integer | 供內部使用。 |
minvalue | bigint | 區塊的最小資料值。儲存前 8 個字元做為非數值資料的 64 位元整數。用於磁碟掃描。 |
maxvalue | bigint | 區塊的最大資料值。儲存前 8 個字元做為非數值資料的 64 位元整數。用於磁碟掃描。 |
sb_pos | integer | 磁碟上的超級區塊位置的內部 Amazon Redshift 識別碼。 |
pinned | integer | 區塊是否固定至記憶體做為預載的一部分。0 = false;1 = true。預設為 false。 |
on_disk | integer | 區塊是否已自動儲存於磁碟。0 = false;1 = true。預設為 false。 |
modified | integer | 區塊是否已修改。0 = false;1 = true。預設為 false。 |
hdr_modified | integer | 區塊標頭是否已修改。0 = false;1 = true。預設為 false。 |
unsorted | integer | 區塊是否未排序。0 = false;1 = true。預設為 true。 |
tombstone | integer | 供內部使用。 |
preferred_diskno | integer | 區塊應處於開啟狀態的磁碟數量 (無論磁碟是否故障)。一旦磁碟修復,區塊將移回該磁碟。 |
temporary | integer | 無論區塊是否包含暫存資料,例如來自暫存資料表或中繼查詢結果。0 = false;1 = true。預設為 false。 |
newblock | integer | 指出區塊是否是新的 (true) 或不曾遞交至磁碟 (false)。0 = false;1 = true。 |
num_readers | integer | 每個區塊上的參考數量。 |
flags | integer | 區塊標頭檔內部 Amazon Redshift 旗標。 |
範例查詢
STV_BLOCKLIST 在每個配置的磁碟區塊上包含一個資料列,因此選取所有資料列的查詢可能會傳回數量非常大的資料列。建議僅適用彙總查詢搭配 STV_BLOCKLIST。
SVV_DISKUSAGE 檢視以更友善使用者的格式提供類似的資訊;但是,以下範例示範 STV_BLOCKLIST 資料表的其中一種用法。
若要判斷 VENUE 資料表中各個欄位使用的 1 MB 區塊數,請輸入以下查詢:
select col, count(*)
from stv_blocklist, stv_tbl_perm
where stv_blocklist.tbl = stv_tbl_perm.id
and stv_blocklist.slice = stv_tbl_perm.slice
and stv_tbl_perm.name = 'venue'
group by col
order by col;
此查詢會傳回配置於 VENUE 資料表中各個欄位的 1 MB 磁碟區塊數,以下列範例資料呈現:
col | count
-----+-------
0 | 4
1 | 4
2 | 4
3 | 4
4 | 4
5 | 4
7 | 4
8 | 4
(8 rows)
以下查詢顯示資料表資料是否實際發佈至所有分割:
select trim(name) as table, stv_blocklist.slice, stv_tbl_perm.rows
from stv_blocklist,stv_tbl_perm
where stv_blocklist.tbl=stv_tbl_perm.id
and stv_tbl_perm.slice=stv_blocklist.slice
and stv_blocklist.id > 10000 and name not like '%#m%'
and name not like 'systable%'
group by name, stv_blocklist.slice, stv_tbl_perm.rows
order by 3 desc;
此查詢會產生下列範例輸出,顯示具有最多資料列之資料表的偶數資料分佈:
table | slice | rows
----------+-------+-------
listing | 13 | 10527
listing | 14 | 10526
listing | 8 | 10526
listing | 9 | 10526
listing | 7 | 10525
listing | 4 | 10525
listing | 17 | 10525
listing | 11 | 10525
listing | 5 | 10525
listing | 18 | 10525
listing | 12 | 10525
listing | 3 | 10525
listing | 10 | 10525
listing | 2 | 10524
listing | 15 | 10524
listing | 16 | 10524
listing | 6 | 10524
listing | 19 | 10524
listing | 1 | 10523
listing | 0 | 10521
...
(180 rows)
下列查詢可判斷是否有任何已刪除標記的區塊已遞交至磁碟:
select slice, col, tbl, blocknum, newblock
from stv_blocklist
where tombstone > 0;
slice | col | tbl | blocknum | newblock
-------+-----+--------+----------+----------
4 | 0 | 101285 | 0 | 1
4 | 2 | 101285 | 0 | 1
4 | 4 | 101285 | 1 | 1
5 | 2 | 101285 | 0 | 1
5 | 0 | 101285 | 0 | 1
5 | 1 | 101285 | 0 | 1
5 | 4 | 101285 | 1 | 1
...
(24 rows)