no estimate block count and auto gather stats in mysqltest

This commit is contained in:
wangt1xiuyi
2023-08-29 06:40:40 +00:00
committed by ob-robot
parent 6dae488704
commit 29f839ec8e
10 changed files with 28 additions and 35 deletions

View File

@ -5164,9 +5164,14 @@ int ObDbmsStats::gather_database_stats_job_proc(sql::ObExecContext &ctx,
number::ObNumber num_duration;
int64_t duration_time = -1;
int64_t succeed_cnt = 0;
bool no_auto_gather = (OB_E(EventTable::EN_LEADER_STORAGE_ESTIMATION) OB_SUCCESS) != OB_SUCCESS;
if (OB_FAIL(check_statistic_table_writeable(ctx))) {
ret = OB_SUCCESS;
LOG_INFO("auto gather database statistics abort because of statistic table is unwriteable");
} else if (!ctx.get_my_session()->is_user_session() && no_auto_gather) {
//do nothing
LOG_INFO("auto gather stat abort because of the trace point and not user seesion",
K(ctx.get_my_session()->is_user_session()), K(no_auto_gather));
} else if (lib::is_oracle_mode() && !params.empty() && !params.at(0).is_null() &&
OB_FAIL(params.at(0).get_number(num_duration))) {
LOG_WARN("failed to get duration", K(ret), K(params.at(0)));

View File

@ -1049,8 +1049,13 @@ int ObEstimateBlockPrefs::check_pref_value_validity(ObTableStatParam *param/*def
int ret = OB_SUCCESS;
if (pvalue_.empty() ||
0 == pvalue_.case_compare("TRUE")) {
bool no_estimate_block = (OB_E(EventTable::EN_LEADER_STORAGE_ESTIMATION) OB_SUCCESS) != OB_SUCCESS;
if (param != NULL) {
param->need_estimate_block_ = true;
if (no_estimate_block) {
param->need_estimate_block_ = false;
} else {
param->need_estimate_block_ = true;
}
}
} else if (0 == pvalue_.case_compare("FALSE")) {
if (param != NULL) {

View File

@ -2070,7 +2070,9 @@ int ObOptStatSqlService::update_opt_stat_task_stat(const ObOptStatTaskInfo &task
ObSqlString value_str;
int64_t affected_rows = 0;
const uint64_t tenant_id = gen_meta_tenant_id(task_info.tenant_id_);
if (OB_FAIL(get_gather_stat_task_value(task_info, value_str))) {
if (!is_valid_tenant_id(tenant_id)) {
//do nothing
} else if (OB_FAIL(get_gather_stat_task_value(task_info, value_str))) {
LOG_WARN("failed to get gather stat values list", K(ret));
} else if (OB_FAIL(raw_sql.append_fmt(INSERT_TASK_OPT_STAT_GATHER_SQL,
share::OB_ALL_TASK_OPT_STAT_GATHER_HISTORY_TNAME,
@ -2105,7 +2107,9 @@ int ObOptStatSqlService::update_opt_stat_gather_stat(const ObOptStatGatherStat &
ObSqlString value_str;
int64_t affected_rows = 0;
const uint64_t tenant_id = gen_meta_tenant_id(gather_stat.get_tenant_id());
if (OB_FAIL(get_gather_stat_value(gather_stat, value_str))) {
if (!is_valid_tenant_id(tenant_id)) {
//do nothing
} else if (OB_FAIL(get_gather_stat_value(gather_stat, value_str))) {
LOG_WARN("failed to get gather stat value", K(ret));
} else if (OB_FAIL(raw_sql.append_fmt(INSERT_TABLE_OPT_STAT_GATHER_SQL,
share::OB_ALL_TABLE_OPT_STAT_GATHER_HISTORY_TNAME,

View File

@ -1,8 +0,0 @@
connect (obsys_explain,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_explain;
--disable_query_log
alter system set_tp tp_no = 918, error_code = 0, frequency = 1;
--enable_query_log
disconnect obsys_explain;
connection default;
sleep 6;

View File

@ -1,7 +0,0 @@
connect (obsys_explain,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_explain;
--disable_query_log
alter system set_tp tp_no = 918, error_code = 4016, frequency = 1;
--enable_query_log
disconnect obsys_explain;
connection default;

View File

@ -417,7 +417,7 @@ CREATE TABLE `t1` (
);
create sequence s1 cache 10000000;
insert into t1 select s1.nextval c1, s1.nextval c2, s1.nextval c3 from table(generator(20000));
explain SELECT t29_25.c1, t29_25.c8
explain basic SELECT t29_25.c1, t29_25.c8
FROM (SELECT (SELECT t29_25.c1
FROM t1 AS t29_25
ORDER BY 1 DESC
@ -428,15 +428,15 @@ FROM t1 AS t29_25) AS t29_25
GROUP BY t29_25.c1, t29_25.c8
HAVING Count(t29_25.c4) <> 990;
Query Plan
=======================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------------
|0 |HASH GROUP BY | |5 |2614 |
|1 |└─SUBPLAN FILTER | |9999 |1598 |
|2 | ├─TABLE FULL SCAN |t29_25|9999 |1004 |
|3 | └─TOP-N SORT | |1 |568 |
|4 | └─TABLE FULL SCAN|t29_25|9999 |541 |
=======================================================
=================================
|ID|OPERATOR |NAME |
---------------------------------
|0 |HASH GROUP BY | |
|1 |└─SUBPLAN FILTER | |
|2 | ├─TABLE FULL SCAN |t29_25|
|3 | └─TOP-N SORT | |
|4 | └─TABLE FULL SCAN|t29_25|
=================================
Outputs & filters:
-------------------------------------
0 - output([:0], [t29_25.c8]), filter([T_FUN_COUNT(t29_25.c4) != 990]), rowset=256

View File

@ -268,7 +268,7 @@ CREATE TABLE `t1` (
create sequence s1 cache 10000000;
insert into t1 select s1.nextval c1, s1.nextval c2, s1.nextval c3 from table(generator(20000));
explain SELECT t29_25.c1, t29_25.c8
explain basic SELECT t29_25.c1, t29_25.c8
FROM (SELECT (SELECT t29_25.c1
FROM t1 AS t29_25
ORDER BY 1 DESC

View File

@ -1,4 +1,3 @@
--source mysql_test/include/explain_init.inc
--disable_query_log
set @@session.explicit_defaults_for_timestamp=off;
--enable_query_log
@ -345,4 +344,3 @@ drop table t2;
--disable_warnings
drop table if exists t2, t7, t8, t9, BB, CC;
--enable_warnings
--source mysql_test/include/explain_end.inc

View File

@ -1,4 +1,3 @@
--source mysql_test/include/explain_init.inc
--disable_query_log
#set @@session.explicit_defaults_for_timestamp=off;
--enable_query_log
@ -572,4 +571,3 @@ SELECT col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_deci
ORDER BY col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk;
drop database union_sort_opt_db;
--source mysql_test/include/explain_end.inc

View File

@ -1,4 +1,3 @@
--source mysql_test/include/explain_init.inc
# owner: dachuan.sdc
# owner group: sql2
# tags: optimizer
@ -148,4 +147,3 @@ select sign( cast(a2 as char(1024)) ) , sign( cast(a4 as char(1024)) ) from t2 f
--echo #
select sign(1E-300) from dual;
select sign(1E-400) from dual;
--source mysql_test/include/explain_end.inc