[FEAT MERGE] Support index usage monitoring
This commit is contained in:
		@ -7141,6 +7141,385 @@ int ObInnerTableSchema::all_aux_stat_schema(ObTableSchema &table_schema)
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ObInnerTableSchema::all_index_usage_info_schema(ObTableSchema &table_schema)
 | 
			
		||||
{
 | 
			
		||||
  int ret = OB_SUCCESS;
 | 
			
		||||
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;
 | 
			
		||||
 | 
			
		||||
  //generated fields:
 | 
			
		||||
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
 | 
			
		||||
  table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID);
 | 
			
		||||
  table_schema.set_database_id(OB_SYS_DATABASE_ID);
 | 
			
		||||
  table_schema.set_table_id(OB_ALL_INDEX_USAGE_INFO_TID);
 | 
			
		||||
  table_schema.set_rowkey_split_pos(0);
 | 
			
		||||
  table_schema.set_is_use_bloomfilter(false);
 | 
			
		||||
  table_schema.set_progressive_merge_num(0);
 | 
			
		||||
  table_schema.set_rowkey_column_num(2);
 | 
			
		||||
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
 | 
			
		||||
  table_schema.set_table_type(SYSTEM_TABLE);
 | 
			
		||||
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
 | 
			
		||||
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_INDEX_USAGE_INFO_TNAME))) {
 | 
			
		||||
      LOG_ERROR("fail to set table_name", K(ret));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
 | 
			
		||||
      LOG_ERROR("fail to set compress_func_name", K(ret));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
 | 
			
		||||
  table_schema.set_charset_type(ObCharset::get_default_charset());
 | 
			
		||||
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ObObj gmt_create_default;
 | 
			
		||||
    ObObj gmt_create_default_null;
 | 
			
		||||
 | 
			
		||||
    gmt_create_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG);
 | 
			
		||||
    gmt_create_default_null.set_null();
 | 
			
		||||
    ADD_COLUMN_SCHEMA_TS_T("gmt_create", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObTimestampType,  //column_type
 | 
			
		||||
      CS_TYPE_BINARY,//collation_type
 | 
			
		||||
      0, //column length
 | 
			
		||||
      -1, //column_precision
 | 
			
		||||
      6, //column_scale
 | 
			
		||||
      true,//is nullable
 | 
			
		||||
      false, //is_autoincrement
 | 
			
		||||
      false, //is_on_update_for_timestamp
 | 
			
		||||
      gmt_create_default_null,
 | 
			
		||||
      gmt_create_default)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ObObj gmt_modified_default;
 | 
			
		||||
    ObObj gmt_modified_default_null;
 | 
			
		||||
 | 
			
		||||
    gmt_modified_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG);
 | 
			
		||||
    gmt_modified_default_null.set_null();
 | 
			
		||||
    ADD_COLUMN_SCHEMA_TS_T("gmt_modified", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObTimestampType,  //column_type
 | 
			
		||||
      CS_TYPE_BINARY,//collation_type
 | 
			
		||||
      0, //column length
 | 
			
		||||
      -1, //column_precision
 | 
			
		||||
      6, //column_scale
 | 
			
		||||
      true,//is nullable
 | 
			
		||||
      false, //is_autoincrement
 | 
			
		||||
      true, //is_on_update_for_timestamp
 | 
			
		||||
      gmt_modified_default_null,
 | 
			
		||||
      gmt_modified_default)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("tenant_id", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      1, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("object_id", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      2, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("name", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObVarcharType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      128, //column_length
 | 
			
		||||
      -1, //column_precision
 | 
			
		||||
      -1, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("owner", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObVarcharType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      128, //column_length
 | 
			
		||||
      -1, //column_precision
 | 
			
		||||
      -1, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("total_access_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("total_exec_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("total_rows_returned", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_0_access_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_1_access_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_2_10_access_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_2_10_rows_returned", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_11_100_access_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_11_100_rows_returned", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_101_1000_access_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_101_1000_rows_returned", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_1000_plus_access_count", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA("bucket_1000_plus_rows_returned", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObIntType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(int64_t), //column_length
 | 
			
		||||
      20, //column_precision
 | 
			
		||||
      0, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false); //is_autoincrement
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA_TS("last_used", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObTimestampType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(ObPreciseDateTime), //column_length
 | 
			
		||||
      -1, //column_precision
 | 
			
		||||
      -1, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false, //is_autoincrement
 | 
			
		||||
      false); //is_on_update_for_timestamp
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (OB_SUCC(ret)) {
 | 
			
		||||
    ADD_COLUMN_SCHEMA_TS("last_flush_time", //column_name
 | 
			
		||||
      ++column_id, //column_id
 | 
			
		||||
      0, //rowkey_id
 | 
			
		||||
      0, //index_id
 | 
			
		||||
      0, //part_key_pos
 | 
			
		||||
      ObTimestampType, //column_type
 | 
			
		||||
      CS_TYPE_INVALID, //column_collation_type
 | 
			
		||||
      sizeof(ObPreciseDateTime), //column_length
 | 
			
		||||
      -1, //column_precision
 | 
			
		||||
      -1, //column_scale
 | 
			
		||||
      false, //is_nullable
 | 
			
		||||
      false, //is_autoincrement
 | 
			
		||||
      false); //is_on_update_for_timestamp
 | 
			
		||||
  }
 | 
			
		||||
  table_schema.set_index_using_type(USING_BTREE);
 | 
			
		||||
  table_schema.set_row_store_type(ENCODING_ROW_STORE);
 | 
			
		||||
  table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL);
 | 
			
		||||
  table_schema.set_progressive_merge_round(1);
 | 
			
		||||
  table_schema.set_storage_format_version(3);
 | 
			
		||||
  table_schema.set_tablet_id(OB_ALL_INDEX_USAGE_INFO_TID);
 | 
			
		||||
  table_schema.set_aux_lob_meta_tid(OB_ALL_INDEX_USAGE_INFO_AUX_LOB_META_TID);
 | 
			
		||||
  table_schema.set_aux_lob_piece_tid(OB_ALL_INDEX_USAGE_INFO_AUX_LOB_PIECE_TID);
 | 
			
		||||
 | 
			
		||||
  table_schema.set_max_used_column_id(column_id);
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
} // end namespace share
 | 
			
		||||
} // end namespace oceanbase
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user