如需在 Azure 入口網站中使用這些查詢的相關資訊,請參閱 Log Analytics 教學課程。 如需 REST API,請參閱 查詢。
膨脹率
每個資料庫目前膨脹率的摘要。
// If required to get the snapshot on a certain date and time just filter on TimeGenerated column, like:
// where TimeGenerated between (datetime('2023-03-01 16:00') .. datetime('2023-03-01 19:00'))
PGSQLAutovacuumStats
| extend ts=bin(TimeGenerated,5m)
| summarize arg_max(ts,LiveRowsCount,DeadRowsCount) by DatabaseName, SchemaName
| where DatabaseName !in ('azure_maintenance', 'azure_sys') //exclude system database
| where SchemaName !in ('pg_catalog','information_schema', 'pg_toast') //exclude system schemas
| summarize TotalLiveRows=sum(LiveRowsCount), TotalDeadRows=sum(DeadRowsCount) by DatabaseName
| extend BloatRatio=toreal(TotalDeadRows)/toreal(TotalLiveRows)*100
| extend BloatRatio = iff( isnan(BloatRatio), 0.0, BloatRatio)
| project DatabaseName,TotalLiveRows,TotalDeadRows, BloatRatio
| order by BloatRatio desc
真空統計
每個資料庫已清空的資料表總數摘要。
// If required to get the snapshot on a certain date and time just filter on TimeGenerated column, like:
// where TimeGenerated between (datetime('2023-03-01 16:00') .. datetime('2023-03-01 19:00'))
PGSQLAutovacuumStats
| extend ts=bin(TimeGenerated,5m)
| summarize arg_max(ts,TablesCount,TablesVacuumedCount,TablesAutovacuumedCount) by DatabaseName, SchemaName
| where DatabaseName !in ('azure_maintenance', 'azure_sys') //exclude system database
| where SchemaName !in ('pg_catalog','information_schema', 'pg_toast') //exclude system schemas
| summarize TotalTables=sum(TablesCount), TablesVaccumed=sum(TablesVacuumedCount), TablesAutoVaccumed=sum(TablesAutovacuumedCount) by DatabaseName
| order by TotalTables desc
分析統計資料
每個資料庫所分析的表格總數摘要。
// If required to get the snapshot on a certain date and time just filter on TimeGenerated column, like:
// where TimeGenerated between (datetime('2023-03-01 16:00') .. datetime('2023-03-01 19:00'))
PGSQLAutovacuumStats
| extend ts=bin(TimeGenerated,5m)
| summarize arg_max(ts,TablesCount,TablesAnalyzedCount,TablesAutoanalyzedCount) by DatabaseName, SchemaName
| where DatabaseName !in ('azure_maintenance', 'azure_sys') //exclude system database
| where SchemaName !in ('pg_catalog','information_schema', 'pg_toast') //exclude system schemas
| summarize TotalTables=sum(TablesCount), TablesAnalyzed=sum(TablesAnalyzedCount), TablesAutoAnalyzed=sum(TablesAutoanalyzedCount) by DatabaseName
| order by TotalTables desc