support collecting table scan info into sql_plan_monitor

This commit is contained in:
raywill
2023-04-03 19:41:28 +00:00
committed by ob-robot
parent db6535d4d2
commit 03809198e1
3 changed files with 27 additions and 0 deletions

View File

@ -52,6 +52,11 @@ SQL_MONITOR_STATNAME_DEF(SORT_DUMP_DATA_TIME, sql_monitor_statname::INT, "sort d
// SSTABLE INSERT
SQL_MONITOR_STATNAME_DEF(DDL_TASK_ID, sql_monitor_statname::INT, "ddl task id", "sort ddl task id")
SQL_MONITOR_STATNAME_DEF(SSTABLE_INSERT_ROW_COUNT, sql_monitor_statname::INT, "sstable insert row count", "sstable insert row count")
// Table Scan stat
SQL_MONITOR_STATNAME_DEF(IO_READ_BYTES, sql_monitor_statname::CAPACITY, "total io bytes read from disk", "total io bytes read from storage")
SQL_MONITOR_STATNAME_DEF(TOTAL_READ_BYTES, sql_monitor_statname::CAPACITY, "total bytes processed by storage", "total bytes processed by storage, including memtable")
SQL_MONITOR_STATNAME_DEF(TOTAL_READ_ROW_COUNT, sql_monitor_statname::INT, "total rows processed by storage", "total rows processed by storage, including memtable")
//end
SQL_MONITOR_STATNAME_DEF(MONITOR_STATNAME_END, sql_monitor_statname::INVALID, "monitor end", "monitor stat name end")
#endif

View File

@ -1305,6 +1305,9 @@ int ObTableScanOp::inner_close()
LOG_WARN("failed to get next batch",K(ret));
}
}
if (OB_SUCC(ret)) {
fill_sql_plan_monitor_info();
}
if (OB_SUCC(ret)) {
iter_end_ = false;
need_init_before_get_row_ = true;
@ -1313,6 +1316,24 @@ int ObTableScanOp::inner_close()
return ret;
}
void ObTableScanOp::fill_sql_plan_monitor_info()
{
oceanbase::common::ObDiagnoseSessionInfo *di = oceanbase::common::ObDiagnoseSessionInfo::get_local_diagnose_info();
if (OB_LIKELY(di)) {
// Hope to demostrate:
// 1. how many bytes read from io (IO_READ_BYTES)
// 2. how many bytes in total (DATA_BLOCK_READ_CNT + INDEX_BLOCK_READ_CNT) * 16K (approximately, many diff for each table)
// 3. how many rows processed before filtering (MEMSTORE_READ_ROW_COUNT + SSSTORE_READ_ROW_COUNT)
op_monitor_info_.otherstat_1_id_ = ObSqlMonitorStatIds::IO_READ_BYTES;
op_monitor_info_.otherstat_2_id_ = ObSqlMonitorStatIds::TOTAL_READ_BYTES;
op_monitor_info_.otherstat_3_id_ = ObSqlMonitorStatIds::TOTAL_READ_ROW_COUNT;
op_monitor_info_.otherstat_1_value_ = EVENT_GET(ObStatEventIds::IO_READ_BYTES, di);
// NOTE: this is not always accurate, as block size change be change from default 16K to any value
op_monitor_info_.otherstat_2_value_ = (EVENT_GET(ObStatEventIds::DATA_BLOCK_READ_CNT, di) + EVENT_GET(ObStatEventIds::INDEX_BLOCK_READ_CNT, di)) * 16 * 1024;
op_monitor_info_.otherstat_3_value_ = EVENT_GET(ObStatEventIds::MEMSTORE_READ_ROW_COUNT, di) + EVENT_GET(ObStatEventIds::SSSTORE_READ_ROW_COUNT, di);
}
}
int ObTableScanOp::do_init_before_get_row()
{
int ret = OB_SUCCESS;

View File

@ -427,6 +427,7 @@ protected:
ObNewRange &part_range);
int fill_storage_feedback_info();
void fill_sql_plan_monitor_info();
//int extract_scan_ranges();
void fill_table_scan_stat(const ObTableScanStatistic &statistic,
ObTableScanStat &scan_stat) const;