[CP] pruning false range index in skyline pruning
This commit is contained in:
parent
cbd677de94
commit
3095c651ed
File diff suppressed because one or more lines are too long
@ -2421,7 +2421,7 @@ DEFINE_ERROR(OB_ERR_VALUES_CLAUSE_NEED_HAVE_COLUMN, -11000, ER_VALUES_CLAUSE_NEE
|
||||
DEFINE_ERROR(OB_ERR_VALUES_CLAUSE_CANNOT_USE_DEFAULT_VALUES, -11001, ER_VALUES_CLAUSE_CANNOT_USE_DEFAULT_VALUES, "HY000", "A VALUES clause cannot use DEFAULT values, unless used as a source in an INSERT statement.");
|
||||
DEFINE_ORACLE_ERROR_EXT(OB_WRONG_PARTITION_NAME, -11002, ER_WRONG_PARTITION_NAME, "HY000", "Incorrect partition name", "Incorrect partition name '%.*s'", 20000, "invalid partition name", "'%.*s' invalid partition name");
|
||||
DEFINE_ERROR_EXT(OB_ERR_PLUGIN_IS_NOT_LOADED, -11003, ER_PLUGIN_IS_NOT_LOADED, "HY000", "Plugin is not loaded", "Plugin '%.*s' is not loaded");
|
||||
//11004 : OB_EST_DEVIA_TOO_LARGE
|
||||
DEFINE_ERROR_EXT(OB_EST_DEVIA_TOO_LARGE, -11004, -1, "HY000", "Optimizer estimate deviation is too large", "Optimizer estimate deviation is too large 'Operator: %d.%.*s EST:%.ld -> REAL:%ld'");
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_HAS_TYPE_OR_TABLE_DEPENDENT, -11005, -1, "HY000", "cannot drop or replace a type with type or table dependents", 2303, "cannot drop or replace a type with type or table dependents");
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_REPLACE_TYPE_WITH_TABLE_DEPENDENT, -11006, -1, "HY000", "cannot replace a type with table dependents", 22866, "cannot replace a type with table dependents");
|
||||
DEFINE_ERROR_EXT(OB_ERR_UNKNOWN_AUTHID, -11007, ER_UNKNOWN_AUTHID, "HY000", "Unknown authorization ID", "Unknown authorization ID `%.*s`@`%.*s`");
|
||||
|
@ -1383,6 +1383,9 @@ constexpr int OB_CLOG_SLIDE_TIMEOUT = -6322;
|
||||
constexpr int OB_LOG_REPLAY_ERROR = -6323;
|
||||
constexpr int OB_TRY_LOCK_CONFIG_CHANGE_CONFLICT = -6324;
|
||||
constexpr int OB_CLOG_DISK_HANG = -6325;
|
||||
constexpr int OB_TABLE_LOCK_SPLIT_TWICE = -6326;
|
||||
constexpr int OB_TABLE_LOCK_IS_SPLITTING = -6327;
|
||||
constexpr int OB_TABLE_LOCK_SPLIT_FAIL = -6328;
|
||||
constexpr int OB_ELECTION_WARN_LOGBUF_FULL = -7000;
|
||||
constexpr int OB_ELECTION_WARN_LOGBUF_EMPTY = -7001;
|
||||
constexpr int OB_ELECTION_WARN_NOT_RUNNING = -7002;
|
||||
@ -1834,6 +1837,7 @@ constexpr int OB_ERR_VALUES_CLAUSE_NEED_HAVE_COLUMN = -11000;
|
||||
constexpr int OB_ERR_VALUES_CLAUSE_CANNOT_USE_DEFAULT_VALUES = -11001;
|
||||
constexpr int OB_WRONG_PARTITION_NAME = -11002;
|
||||
constexpr int OB_ERR_PLUGIN_IS_NOT_LOADED = -11003;
|
||||
constexpr int OB_EST_DEVIA_TOO_LARGE = -11004;
|
||||
constexpr int OB_ERR_HAS_TYPE_OR_TABLE_DEPENDENT = -11005;
|
||||
constexpr int OB_ERR_REPLACE_TYPE_WITH_TABLE_DEPENDENT = -11006;
|
||||
constexpr int OB_ERR_UNKNOWN_AUTHID = -11007;
|
||||
@ -3468,6 +3472,9 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
#define OB_LOG_REPLAY_ERROR__USER_ERROR_MSG "log replay error"
|
||||
#define OB_TRY_LOCK_CONFIG_CHANGE_CONFLICT__USER_ERROR_MSG "ob trying to lock config change conflicts"
|
||||
#define OB_CLOG_DISK_HANG__USER_ERROR_MSG "ob clog disk hang"
|
||||
#define OB_TABLE_LOCK_SPLIT_TWICE__USER_ERROR_MSG "table lock has been splitted before, can not be splitted again"
|
||||
#define OB_TABLE_LOCK_IS_SPLITTING__USER_ERROR_MSG "table lock is being splitted, can not be splitted again"
|
||||
#define OB_TABLE_LOCK_SPLIT_FAIL__USER_ERROR_MSG "table lock splitting failed"
|
||||
#define OB_ELECTION_WARN_LOGBUF_FULL__USER_ERROR_MSG "The log buffer is full"
|
||||
#define OB_ELECTION_WARN_LOGBUF_EMPTY__USER_ERROR_MSG "The log buffer is empty"
|
||||
#define OB_ELECTION_WARN_NOT_RUNNING__USER_ERROR_MSG "The object is not running"
|
||||
@ -4043,6 +4050,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
#define OB_ERR_VALUES_CLAUSE_CANNOT_USE_DEFAULT_VALUES__USER_ERROR_MSG "A VALUES clause cannot use DEFAULT values, unless used as a source in an INSERT statement."
|
||||
#define OB_WRONG_PARTITION_NAME__USER_ERROR_MSG "Incorrect partition name '%.*s'"
|
||||
#define OB_ERR_PLUGIN_IS_NOT_LOADED__USER_ERROR_MSG "Plugin '%.*s' is not loaded"
|
||||
#define OB_EST_DEVIA_TOO_LARGE__USER_ERROR_MSG "Optimizer estimate deviation is too large 'Operator: %d.%.*s EST:%.ld -> REAL:%ld'"
|
||||
#define OB_ERR_HAS_TYPE_OR_TABLE_DEPENDENT__USER_ERROR_MSG "cannot drop or replace a type with type or table dependents"
|
||||
#define OB_ERR_REPLACE_TYPE_WITH_TABLE_DEPENDENT__USER_ERROR_MSG "cannot replace a type with table dependents"
|
||||
#define OB_ERR_UNKNOWN_AUTHID__USER_ERROR_MSG "Unknown authorization ID `%.*s`@`%.*s`"
|
||||
@ -5684,6 +5692,9 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
#define OB_LOG_REPLAY_ERROR__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -6323, log replay error"
|
||||
#define OB_TRY_LOCK_CONFIG_CHANGE_CONFLICT__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -6324, ob trying to lock config change conflicts"
|
||||
#define OB_CLOG_DISK_HANG__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -6325, ob clog disk hang"
|
||||
#define OB_TABLE_LOCK_SPLIT_TWICE__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -6326, table lock has been splitted before, can not be splitted again"
|
||||
#define OB_TABLE_LOCK_IS_SPLITTING__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -6327, table lock is being splitted, can not be splitted again"
|
||||
#define OB_TABLE_LOCK_SPLIT_FAIL__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -6328, table lock splitting failed"
|
||||
#define OB_ELECTION_WARN_LOGBUF_FULL__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -7000, The log buffer is full"
|
||||
#define OB_ELECTION_WARN_LOGBUF_EMPTY__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -7001, The log buffer is empty"
|
||||
#define OB_ELECTION_WARN_NOT_RUNNING__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -7002, The object is not running"
|
||||
@ -6259,6 +6270,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
#define OB_ERR_VALUES_CLAUSE_CANNOT_USE_DEFAULT_VALUES__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -11001, A VALUES clause cannot use DEFAULT values, unless used as a source in an INSERT statement."
|
||||
#define OB_WRONG_PARTITION_NAME__ORA_USER_ERROR_MSG "ORA-20000: '%.*s' invalid partition name"
|
||||
#define OB_ERR_PLUGIN_IS_NOT_LOADED__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -11003, Plugin '%.*s' is not loaded"
|
||||
#define OB_EST_DEVIA_TOO_LARGE__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -11004, Optimizer estimate deviation is too large 'Operator: %d.%.*s EST:%.ld -> REAL:%ld'"
|
||||
#define OB_ERR_HAS_TYPE_OR_TABLE_DEPENDENT__ORA_USER_ERROR_MSG "ORA-02303: cannot drop or replace a type with type or table dependents"
|
||||
#define OB_ERR_REPLACE_TYPE_WITH_TABLE_DEPENDENT__ORA_USER_ERROR_MSG "ORA-22866: cannot replace a type with table dependents"
|
||||
#define OB_ERR_UNKNOWN_AUTHID__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -11007, Unknown authorization ID `%.*s`@`%.*s`"
|
||||
@ -6285,7 +6297,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
#define OB_ERR_DATA_TOO_LONG_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-12899: value too large for column %.*s (actual: %ld, maximum: %ld)"
|
||||
#define OB_ERR_INVALID_DATE_MSG_FMT_V2__ORA_USER_ERROR_MSG "ORA-01861: Incorrect datetime value for column '%.*s' at row %ld"
|
||||
|
||||
extern int g_all_ob_errnos[2212];
|
||||
extern int g_all_ob_errnos[2216];
|
||||
|
||||
const char *ob_error_name(const int oberr);
|
||||
const char* ob_error_cause(const int oberr);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "lib/file/file_directory_utils.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/optimizer/ob_dynamic_sampling.h"
|
||||
#include "sql/optimizer/ob_skyline_prunning.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::share;
|
||||
@ -830,6 +831,41 @@ int ObOptimizerTraceImpl::append(const ObDSResultItem &ds_result)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObOptimizerTraceImpl::append(const ObSkylineDim &dim)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
switch (dim.get_dim_type()) {
|
||||
case ObSkylineDim::INDEX_BACK: {
|
||||
const ObIndexBackDim &index_dim = static_cast<const ObIndexBackDim &>(dim);
|
||||
append("[index back dim] need index back:", index_dim.need_index_back_);
|
||||
append(", has interesting order:", index_dim.has_interesting_order_);
|
||||
append(", can extract range:", index_dim.can_extract_range_);
|
||||
append(", filter columns:", common::ObArrayWrap<uint64_t>(index_dim.filter_column_ids_, index_dim.filter_column_cnt_));
|
||||
break;
|
||||
}
|
||||
case ObSkylineDim::INTERESTING_ORDER: {
|
||||
const ObInterestOrderDim &order_dim = static_cast<const ObInterestOrderDim &>(dim);
|
||||
append("[intersting order dim] is interesting order:", order_dim.is_interesting_order_);
|
||||
append(", need index back:", order_dim.need_index_back_);
|
||||
append(", can extract range:", order_dim.can_extract_range_);
|
||||
append(", column ids:", common::ObArrayWrap<uint64_t>(order_dim.column_ids_, order_dim.column_cnt_));
|
||||
append(", filter columns:", common::ObArrayWrap<uint64_t>(order_dim.filter_column_ids_, order_dim.filter_column_cnt_));
|
||||
break;
|
||||
}
|
||||
case ObSkylineDim::QUERY_RANGE: {
|
||||
const ObQueryRangeDim &range_dim = static_cast<const ObQueryRangeDim &>(dim);
|
||||
append("[query range dim] contain false range:", range_dim.contain_always_false_);
|
||||
append(", rowkey ids:", common::ObArrayWrap<uint64_t>(range_dim.column_ids_, range_dim.column_cnt_));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
append("unknown dim");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObOptimizerTraceImpl::trace_env()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -44,6 +44,7 @@ class TableItem;
|
||||
class ObSQLSessionInfo;
|
||||
struct CandidatePlan;
|
||||
class OptSystemStat;
|
||||
class ObSkylineDim;
|
||||
|
||||
class ObOptimizerTraceImpl;
|
||||
|
||||
@ -267,6 +268,7 @@ public:
|
||||
int append(const ObShardingInfo *info);
|
||||
int append(const CandidatePlan &plan);
|
||||
int append(const ObDSResultItem &ds_result);
|
||||
int append(const ObSkylineDim &dim);
|
||||
/***********************************************/
|
||||
////print template type
|
||||
/***********************************************/
|
||||
@ -285,14 +287,14 @@ public:
|
||||
typename std::enable_if<std::is_base_of<ObIArray<ObRawExpr*>, T>::value, int>::type
|
||||
append(const T& value);
|
||||
|
||||
//for ObIArray<uint64_t>
|
||||
//for ObIArrayWrap<uint64_t>
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_base_of<ObIArray<uint64_t>, T>::value, int>::type
|
||||
typename std::enable_if<std::is_base_of<ObIArrayWrap<uint64_t>, T>::value, int>::type
|
||||
append(const T& value);
|
||||
|
||||
//for ObIArray<int64_t>
|
||||
//for ObIArrayWrap<int64_t>
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_base_of<ObIArray<int64_t>, T>::value, int>::type
|
||||
typename std::enable_if<std::is_base_of<ObIArrayWrap<int64_t>, T>::value, int>::type
|
||||
append(const T& value);
|
||||
|
||||
//for ObIArray<ObDSResultItem>
|
||||
@ -399,7 +401,7 @@ ObOptimizerTraceImpl::append(const T& value)
|
||||
|
||||
//for ObIArray<uint64_t>
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_base_of<ObIArray<uint64_t>, T>::value, int>::type
|
||||
typename std::enable_if<std::is_base_of<ObIArrayWrap<uint64_t>, T>::value, int>::type
|
||||
ObOptimizerTraceImpl::append(const T& value)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -416,7 +418,7 @@ ObOptimizerTraceImpl::append(const T& value)
|
||||
|
||||
//for ObIArray<int64_t>
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_base_of<ObIArray<int64_t>, T>::value, int>::type
|
||||
typename std::enable_if<std::is_base_of<ObIArrayWrap<int64_t>, T>::value, int>::type
|
||||
ObOptimizerTraceImpl::append(const T& value)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -2187,7 +2187,7 @@ int ObJoinOrder::cal_dimension_info(const uint64_t table_id, //alias table id
|
||||
ObSEArray<uint64_t, 8> interest_column_ids;
|
||||
ObSEArray<bool, 8> const_column_info;
|
||||
ObSEArray<uint64_t, 8> prefix_range_ids; //for query range compare
|
||||
bool contain_always_false = false; //for always false condition, the index is not comparable
|
||||
bool contain_always_false = false;
|
||||
if (OB_FAIL(extract_interesting_column_ids(ordering_info->get_index_keys(),
|
||||
index_info_entry->get_interesting_order_prefix_count(),
|
||||
interest_column_ids,
|
||||
@ -2221,25 +2221,24 @@ int ObJoinOrder::cal_dimension_info(const uint64_t table_id, //alias table id
|
||||
* (2) interesting_order
|
||||
* (3) query range
|
||||
* */
|
||||
if (contain_always_false) {
|
||||
//包含恒false的条件(or is global index),计划不做剪枝
|
||||
index_dim.set_can_prunning(false);
|
||||
}
|
||||
bool can_extract_range = prefix_range_ids.count() > 0 || contain_always_false;
|
||||
if (OB_FAIL(index_dim.add_index_back_dim(is_index_back,
|
||||
interest_column_ids.count() > 0,
|
||||
prefix_range_ids.count() > 0,
|
||||
can_extract_range,
|
||||
index_schema->get_column_count(),
|
||||
filter_column_ids,
|
||||
*allocator_))) {
|
||||
LOG_WARN("add index back dim failed", K(is_index_back), K(ret));
|
||||
} else if (OB_FAIL(index_dim.add_interesting_order_dim(is_index_back,
|
||||
prefix_range_ids.count() > 0,
|
||||
can_extract_range,
|
||||
filter_column_ids,
|
||||
interest_column_ids,
|
||||
const_column_info,
|
||||
*allocator_))) {
|
||||
LOG_WARN("add interesting order dim failed", K(interest_column_ids), K(ret));
|
||||
} else if (OB_FAIL(index_dim.add_query_range_dim(prefix_range_ids, *allocator_))) {
|
||||
} else if (OB_FAIL(index_dim.add_query_range_dim(prefix_range_ids,
|
||||
*allocator_,
|
||||
contain_always_false))) {
|
||||
LOG_WARN("add query range dimension failed", K(ret));
|
||||
}
|
||||
}
|
||||
@ -2278,6 +2277,7 @@ int ObJoinOrder::skyline_prunning_index(const uint64_t table_id,
|
||||
} else { /*do nothing*/ }
|
||||
} else {
|
||||
//维度统计信息
|
||||
OPT_TRACE_TITLE("BEGIN SKYLINE INDEX PRUNNING");
|
||||
ObSkylineDimRecorder recorder;
|
||||
bool has_add = false;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < valid_index_ids.count(); ++i) {
|
||||
|
@ -358,7 +358,11 @@ int ObQueryRangeDim::compare(const ObSkylineDim &other, CompareStat &status) con
|
||||
"dim_type", get_dim_type(), "other.dim_type", other.get_dim_type());
|
||||
} else {
|
||||
const ObQueryRangeDim &tmp = static_cast<const ObQueryRangeDim &>(other);
|
||||
if (column_cnt_ == 0 && tmp.column_cnt_ == 0) {
|
||||
if (contain_always_false_ && tmp.contain_always_false_) {
|
||||
status = EQUAL;
|
||||
} else if (contain_always_false_ || tmp.contain_always_false_) {
|
||||
status = UNCOMPARABLE;
|
||||
} else if (column_cnt_ == 0 && tmp.column_cnt_ == 0) {
|
||||
status = EQUAL; //both can't not extract query range, equal
|
||||
} else {
|
||||
RangeSubsetComp comp;
|
||||
@ -402,13 +406,16 @@ int ObIndexSkylineDim::compare(const ObIndexSkylineDim &other, ObSkylineDim::Com
|
||||
int ret = OB_SUCCESS;
|
||||
status = ObSkylineDim::EQUAL;
|
||||
int64_t compare_result = 0;
|
||||
LOG_TRACE("begin skyline compare index", KPC(this), K(other));
|
||||
OPT_TRACE("compare index", get_index_id(), "to index", other.get_index_id());
|
||||
OPT_TRACE_BEGIN_SECTION;
|
||||
for (int i = 0; OB_SUCC(ret) && status != ObSkylineDim::UNCOMPARABLE && i < dim_count_; ++i) {
|
||||
const ObSkylineDim *left_dim = skyline_dims_[i];
|
||||
const ObSkylineDim *right_dim = other.skyline_dims_[i];
|
||||
ObSkylineDim::CompareStat tmp_status = ObSkylineDim::UNCOMPARABLE;
|
||||
if (OB_ISNULL(left_dim) || OB_ISNULL(right_dim)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("skeyline dimension should not be null", K(ret), K(i), K(left_dim), K(right_dim));
|
||||
LOG_WARN("skyline dimension should not be null", K(ret), K(i), K(left_dim), K(right_dim));
|
||||
} else if (OB_FAIL(left_dim->compare(*right_dim, tmp_status))) {
|
||||
LOG_WARN("compare skyline dimension failed", K(ret), K(i),
|
||||
K(*left_dim), K(*right_dim));
|
||||
@ -430,6 +437,10 @@ int ObIndexSkylineDim::compare(const ObIndexSkylineDim &other, ObSkylineDim::Com
|
||||
status = ObSkylineDim::UNCOMPARABLE;
|
||||
}
|
||||
}
|
||||
LOG_TRACE("skyline compare dim", K(i), K(tmp_status), K(compare_result), KPC(left_dim), KPC(right_dim));
|
||||
OPT_TRACE("compare dim", static_cast<int64_t>(i), "result:", static_cast<int64_t>(tmp_status));
|
||||
OPT_TRACE("left dim:", *left_dim);
|
||||
OPT_TRACE("right dim:", *right_dim);
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -441,6 +452,9 @@ int ObIndexSkylineDim::compare(const ObIndexSkylineDim &other, ObSkylineDim::Com
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG_TRACE("finish skyline compare index", K(status));
|
||||
OPT_TRACE("compare result (UNCOMPARABLE:-2, RIGHT_DOMINATED:-1, EQUAL:0, LEFT_DOMINATED:1):", static_cast<int64_t>(status));
|
||||
OPT_TRACE_END_SECTION;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -541,7 +555,8 @@ int ObIndexSkylineDim::add_interesting_order_dim(const bool is_index_back,
|
||||
}
|
||||
|
||||
int ObIndexSkylineDim::add_query_range_dim(const ObIArray<uint64_t> &prefix_range_ids,
|
||||
ObIAllocator &allocator)
|
||||
ObIAllocator &allocator,
|
||||
bool contain_always_false)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObQueryRangeDim *dim = NULL;
|
||||
@ -552,6 +567,7 @@ int ObIndexSkylineDim::add_query_range_dim(const ObIArray<uint64_t> &prefix_rang
|
||||
LOG_WARN("failed to create dimension", K(ret));
|
||||
} else {
|
||||
if (OB_SUCC(ret)) {
|
||||
dim->set_contain_always_false(contain_always_false);
|
||||
if (OB_FAIL(dim->add_rowkey_ids(prefix_range_ids))) {
|
||||
LOG_WARN("failed to add rowkey ids", K(ret));
|
||||
} else if (OB_FAIL(add_skyline_dim(*dim))) {
|
||||
@ -570,6 +586,9 @@ int ObSkylineDimRecorder::add_index_dim(const ObIndexSkylineDim &dim, bool &has_
|
||||
has_add = false;
|
||||
ObArray<int64_t> remove_idxs;
|
||||
bool need_add = true;
|
||||
LOG_TRACE("Skyline Pruning try to add index", K(dim));
|
||||
OPT_TRACE("try to add index", dim.get_index_id());
|
||||
OPT_TRACE_BEGIN_SECTION;
|
||||
if (!dim.can_prunning()) {
|
||||
//can't prunning, just add
|
||||
if (OB_FAIL(index_dims_.push_back(&dim))) {
|
||||
@ -577,6 +596,8 @@ int ObSkylineDimRecorder::add_index_dim(const ObIndexSkylineDim &dim, bool &has_
|
||||
} else {
|
||||
has_add = true;
|
||||
}
|
||||
LOG_TRACE("Index can not be pruning");
|
||||
OPT_TRACE("Index can not be pruning");
|
||||
} else {
|
||||
if (OB_FAIL(has_dominate_dim(dim, remove_idxs, need_add))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -597,8 +618,11 @@ int ObSkylineDimRecorder::add_index_dim(const ObIndexSkylineDim &dim, bool &has_
|
||||
has_add = true;
|
||||
}
|
||||
}
|
||||
LOG_TRACE("succeed to add index", K(dim));
|
||||
OPT_TRACE("succeed to add index ", dim.get_index_id());
|
||||
}
|
||||
}
|
||||
OPT_TRACE_END_SECTION;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -636,6 +660,7 @@ int ObSkylineDimRecorder::has_dominate_dim(const ObIndexSkylineDim &dim,
|
||||
const ObIndexSkylineDim *index_dim = index_dims_.at(i);
|
||||
if (!index_dim->can_prunning()) {
|
||||
LOG_TRACE("ignore index that can't not be prunning", K(*index_dim));
|
||||
OPT_TRACE("index", index_dim->get_index_id(), "can't be prunning");
|
||||
} else if (OB_FAIL(index_dim->compare(dim, status))) {
|
||||
LOG_WARN("compare skyline dimension failed", K(ret), K(dim), K(i));
|
||||
} else if (ObSkylineDim::LEFT_DOMINATED == status) {
|
||||
@ -645,6 +670,8 @@ int ObSkylineDimRecorder::has_dominate_dim(const ObIndexSkylineDim &dim,
|
||||
K(ret), K(i), K(remove_idxs), K(*index_dim), K(dim));
|
||||
} else {
|
||||
need_add = false;
|
||||
LOG_TRACE("index is prunning by exists index", KPC(index_dim));
|
||||
OPT_TRACE("index", dim.get_index_id(), "is prunning by index", index_dim->get_index_id());
|
||||
break;//not continue
|
||||
}
|
||||
} else if (ObSkylineDim::RIGHT_DOMINATED == status) {
|
||||
@ -652,6 +679,8 @@ int ObSkylineDimRecorder::has_dominate_dim(const ObIndexSkylineDim &dim,
|
||||
if (OB_FAIL(remove_idxs.push_back(i))) {
|
||||
LOG_WARN("failed to add dominate idx", K(ret));
|
||||
}
|
||||
LOG_TRACE("index rigit dominated exists index", KPC(index_dim));
|
||||
OPT_TRACE("index", dim.get_index_id(), "prune index", index_dim->get_index_id());
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
virtual int compare(const ObSkylineDim &other, CompareStat &status) const = 0;
|
||||
Dimension get_dim_type() const { return dim_type_; }
|
||||
static const int64_t DIM_COUNT = static_cast<int64_t>(MAX_DIM);;
|
||||
TO_STRING_KV(K(dim_type_));
|
||||
VIRTUAL_TO_STRING_KV(K(dim_type_));
|
||||
private:
|
||||
const Dimension dim_type_;
|
||||
};
|
||||
@ -61,6 +61,7 @@ private:
|
||||
class ObIndexBackDim : public ObSkylineDim
|
||||
{
|
||||
public:
|
||||
friend class ObOptimizerTraceImpl;
|
||||
ObIndexBackDim() : ObSkylineDim(INDEX_BACK), need_index_back_(false),
|
||||
has_interesting_order_(true),
|
||||
can_extract_range_(true),
|
||||
@ -75,7 +76,7 @@ public:
|
||||
void set_index_column_cnt(const int64_t size) { index_column_cnt_ = size; }
|
||||
int add_filter_column_ids(const common::ObIArray<uint64_t> &filter_column_ids);
|
||||
virtual int compare(const ObSkylineDim &other, CompareStat &status) const;
|
||||
TO_STRING_KV(K_(need_index_back), K_(has_interesting_order), K_(can_extract_range),
|
||||
VIRTUAL_TO_STRING_KV(K_(need_index_back), K_(has_interesting_order), K_(can_extract_range),
|
||||
K_(index_column_cnt),
|
||||
"restrcit_ids", common::ObArrayWrap<uint64_t>(filter_column_ids_, filter_column_cnt_));
|
||||
private:
|
||||
@ -100,6 +101,7 @@ private:
|
||||
class ObInterestOrderDim : public ObSkylineDim
|
||||
{
|
||||
public:
|
||||
friend class ObOptimizerTraceImpl;
|
||||
ObInterestOrderDim() : ObSkylineDim(INTERESTING_ORDER),
|
||||
is_interesting_order_(false),
|
||||
column_cnt_(0),
|
||||
@ -116,7 +118,7 @@ public:
|
||||
void set_extract_range(const bool can) { can_extract_range_ = can; }
|
||||
int add_filter_column_ids(const common::ObIArray<uint64_t> &filter_column_ids);
|
||||
virtual int compare(const ObSkylineDim &other, CompareStat &status) const;
|
||||
TO_STRING_KV(K_(is_interesting_order),
|
||||
VIRTUAL_TO_STRING_KV(K_(is_interesting_order),
|
||||
K_(column_cnt),
|
||||
"column_ids", common::ObArrayWrap<uint64_t>(column_ids_, column_cnt_),
|
||||
K_(need_index_back),
|
||||
@ -145,17 +147,21 @@ private:
|
||||
class ObQueryRangeDim: public ObSkylineDim
|
||||
{
|
||||
public:
|
||||
friend class ObOptimizerTraceImpl;
|
||||
ObQueryRangeDim() : ObSkylineDim(QUERY_RANGE),
|
||||
column_cnt_(0)
|
||||
column_cnt_(0),
|
||||
contain_always_false_(false)
|
||||
{ MEMSET(column_ids_, 0, sizeof(uint64_t) * common::OB_USER_MAX_ROWKEY_COLUMN_NUMBER);}
|
||||
virtual ~ObQueryRangeDim() {}
|
||||
virtual int compare(const ObSkylineDim &other, CompareStat &status) const;
|
||||
int add_rowkey_ids(const common::ObIArray<uint64_t> &column_ids);
|
||||
TO_STRING_KV(K_(column_cnt),
|
||||
void set_contain_always_false(bool contain_always_false) { contain_always_false_ = contain_always_false; }
|
||||
VIRTUAL_TO_STRING_KV(K_(column_cnt), K_(contain_always_false),
|
||||
"rowkey_ids", common::ObArrayWrap<uint64_t>(column_ids_, column_cnt_));
|
||||
private:
|
||||
int64_t column_cnt_;
|
||||
uint64_t column_ids_[common::OB_USER_MAX_ROWKEY_COLUMN_NUMBER];
|
||||
bool contain_always_false_;
|
||||
};
|
||||
|
||||
struct KeyPrefixComp
|
||||
@ -213,7 +219,8 @@ public:
|
||||
const common::ObIArray<bool> &const_column_info,
|
||||
common::ObIAllocator &allocator);
|
||||
int add_query_range_dim(const common::ObIArray<uint64_t> &prefix_range_ids,
|
||||
common::ObIAllocator &allocator);
|
||||
common::ObIAllocator &allocator,
|
||||
bool contain_always_false);
|
||||
bool can_prunning() const { return can_prunning_; }
|
||||
void set_can_prunning(const bool can) { can_prunning_ = can; }
|
||||
TO_STRING_KV(K_(index_id), K_(dim_count),
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -393,6 +393,44 @@ explain select avg(c1) over (partition by c3 order by c5),
|
||||
max(c1) over (partition by c2, c3, c5)
|
||||
from t9 order by c3, c2, c5;
|
||||
|
||||
# test false range
|
||||
create table t10(pk int primary key, c1 int, c2 int, c3 int, c4 int);
|
||||
create index t10i1 on t10(c1, c2, c3);
|
||||
create index t10i2 on t10(c2, c3);
|
||||
create index t10i3 on t10(c3);
|
||||
create table t11(pk int primary key, c1 int, c2 int);
|
||||
create index t11i1 on t11(c1);
|
||||
create table t12(c1 int, c2 int, c3 int, c4 int, primary key(c1, c2));
|
||||
create index t12i1 on t12(c2);
|
||||
create index t12i2 on t12(c3);
|
||||
|
||||
explain extended_noaddr select 1 from t10 where c1 < 0 and c1 > 0 and c2 = 1;
|
||||
explain extended_noaddr select 1 from t10 where c2 < 0 and c2 > 0 and c3 = 1;
|
||||
explain extended_noaddr select 1 from t10 where c3 < 0 and c3 > 0 and c2 = 1;
|
||||
explain extended_noaddr select 1 from t10 where c2 < 0 and c2 > 0 and c4 = 2;
|
||||
explain extended_noaddr select 1 from t10 where c3 < 0 and c3 > 0 and c4 = 2;
|
||||
explain extended_noaddr select 1 from t10 where c2 < 0 and c2 > 0 and c3 = 1 order by c2;
|
||||
explain extended_noaddr select 1 from t10 where c3 < 0 and c3 > 0 and c2 = 1 order by c3;
|
||||
explain extended_noaddr select 1 from t10 where c2 < 0 and c2 > 0 and c4 = 2 order by c1;
|
||||
explain extended_noaddr select 1 from t10 where c3 < 0 and c3 > 0 and c4 = 2 order by c2;
|
||||
explain extended_noaddr select 1 from t10 where c3 < 0 and c3 > 0 and c4 = 2 order by c3;
|
||||
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0;
|
||||
explain extended_noaddr select 1 from t11 where c1 < 0 and c1 > 0;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c2 = 1;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c2 = 1 order by pk;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c2 = 1 order by c1;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c2 = 1 order by c2;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c1 = 1;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c1 = 1 order by pk;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c1 = 1 order by c1;
|
||||
explain extended_noaddr select 1 from t11 where pk < 0 and pk > 0 and c1 = 1 order by c2;
|
||||
|
||||
explain extended_noaddr select 1 from t12 where c2 < 0 and c2 > 0;
|
||||
explain extended_noaddr select * from t12 where c2 < 0 and c2 > 0;
|
||||
explain extended_noaddr select 1 from t12 where c2 < 0 and c2 > 0 and c3 = 1;
|
||||
explain extended_noaddr select * from t12 where c2 < 0 and c2 > 0 and c3 = 1;
|
||||
|
||||
##complicate
|
||||
#
|
||||
set @@recyclebin = 'off';
|
||||
|
@ -120,7 +120,7 @@ ObIndexSkylineDim *ObSkylinePrunningTest::create_skyline_index_dim(
|
||||
to_array(range_ids, range_cnt, rowkey_array);
|
||||
dummy_const_column_info(interest_cnt, const_column_info);
|
||||
t->add_interesting_order_dim(index_back, range_cnt > 0, filter_array, interest_array, const_column_info, allocator_);
|
||||
t->add_query_range_dim(rowkey_array, allocator_);
|
||||
t->add_query_range_dim(rowkey_array, allocator_, false);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user