Add index filtering based on column value type
This commit is contained in:
parent
512671df85
commit
58b3dd7b99
|
@ -625,28 +625,21 @@ static int32_t sifSetFltParam(SIFParam *left, SIFParam *right, SDataTypeBuf *typ
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int8_t sifCheckNumericTypeSame(uint8_t left, uint8_t right) {
|
|
||||||
if (left != right) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
static int8_t sifShouldUseIndexBasedOnType(SIFParam *left, SIFParam *right) {
|
static int8_t sifShouldUseIndexBasedOnType(SIFParam *left, SIFParam *right) {
|
||||||
if (left->colValType == TSDB_DATA_TYPE_GEOMETRY || right->colValType == TSDB_DATA_TYPE_GEOMETRY) {
|
// not compress
|
||||||
|
if (left->colValType == TSDB_DATA_TYPE_FLOAT) return 0;
|
||||||
|
|
||||||
|
if (left->colValType == TSDB_DATA_TYPE_GEOMETRY || right->colValType == TSDB_DATA_TYPE_GEOMETRY ||
|
||||||
|
left->colValType == TSDB_DATA_TYPE_JSON || right->colValType == TSDB_DATA_TYPE_JSON) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (IS_VAR_DATA_TYPE(left->colValType) && !IS_VAR_DATA_TYPE(right->colValType)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (IS_NUMERIC_TYPE(left->colValType) && !IS_NUMERIC_TYPE(right->colValType)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (IS_NUMERIC_TYPE(left->colValType) && IS_NUMERIC_TYPE(right->colValType)) {
|
|
||||||
if (!sifCheckNumericTypeSame(left->colValType, right->colValType)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(left->colValType)) {
|
||||||
|
if (!IS_VAR_DATA_TYPE(right->colValType)) return 0;
|
||||||
|
} else if (IS_NUMERIC_TYPE(left->colValType)) {
|
||||||
|
if (!IS_NUMERIC_TYPE(right->colValType)) return 0;
|
||||||
|
if (left->colValType != right->colValType) return 0;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFParam *output) {
|
static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFParam *output) {
|
||||||
|
@ -666,9 +659,6 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
|
||||||
ret = indexJsonSearch(arg->ivtIdx, mtm, output->result);
|
ret = indexJsonSearch(arg->ivtIdx, mtm, output->result);
|
||||||
indexMultiTermQueryDestroy(mtm);
|
indexMultiTermQueryDestroy(mtm);
|
||||||
} else {
|
} else {
|
||||||
// if (left->colValType == TSDB_DATA_TYPE_GEOMETRY || right->colValType == TSDB_DATA_TYPE_GEOMETRY) {
|
|
||||||
// return TSDB_CODE_QRY_GEO_NOT_SUPPORT_ERROR;
|
|
||||||
// }
|
|
||||||
int8_t useIndex = sifShouldUseIndexBasedOnType(left, right);
|
int8_t useIndex = sifShouldUseIndexBasedOnType(left, right);
|
||||||
if (!useIndex) {
|
if (!useIndex) {
|
||||||
output->status = SFLT_NOT_INDEX;
|
output->status = SFLT_NOT_INDEX;
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
|
||||||
|
system sh/stop_dnodes.sh
|
||||||
|
system sh/deploy.sh -n dnode1 -i 1
|
||||||
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
sql connect
|
||||||
|
|
||||||
|
print ======== step0
|
||||||
|
$dbPrefix = ta_3_db
|
||||||
|
$tbPrefix = ta_3_tb
|
||||||
|
$mtPrefix = ta_3_mt
|
||||||
|
$lastRowNum = 0
|
||||||
|
$tbNum = 100000
|
||||||
|
$rowNum = 20
|
||||||
|
$totalNum = 200
|
||||||
|
|
||||||
|
print =============== create database
|
||||||
|
sql create database $dbPrefix
|
||||||
|
sql use $dbPrefix
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 tinyint, t1c tinyint)
|
||||||
|
$i = 0
|
||||||
|
$tinyLimit = 127
|
||||||
|
$tinyTable = tinyTable
|
||||||
|
while $i < $tinyLimit
|
||||||
|
$tb = $tinyTable . $i
|
||||||
|
sql insert into $tb using $mtPrefix tags( $i , $i ) values( now , $i )
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
$maxTinyLimit = 200
|
||||||
|
|
||||||
|
# 1. compress index and no-index to verify resultset
|
||||||
|
# 2. compress resultset of index filter and scalar filter
|
||||||
|
while $i < $maxTinyLimit
|
||||||
|
sql select * from $mtPrefix where t1 <= $i
|
||||||
|
$lastRowNum = $rows
|
||||||
|
|
||||||
|
sql select * from $mtPrefix where t1c <= $i
|
||||||
|
if $lastRowNum != $rows then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
|
||||||
|
$tbPrefix = ta_3_tb_c
|
||||||
|
$mtPrefix = ta_3_mt_c
|
||||||
|
$colPrefix = 'col'
|
||||||
|
sql create table if not exists $mtPrefix (ts timestamp, c1 int) tags (t1 nchar(18), t1c nchar(18))
|
||||||
|
$i = 0
|
||||||
|
$tinyLimit = 127
|
||||||
|
while $i < $tinyLimit
|
||||||
|
$tb = $tbPrefix . $i
|
||||||
|
sql insert into $tb using $mtPrefix tags( $colPrefix , $colPrefix ) values( now , $i )
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
$i = 0
|
||||||
|
$maxTinyLimit = 200
|
||||||
|
|
||||||
|
# 1. compress index and no-index to verify resultset
|
||||||
|
# 2. compress resultset of index filter and scalar filter
|
||||||
|
while $i < $maxTinyLimit
|
||||||
|
sql select * from $mtPrefix where t1 <= $i
|
||||||
|
$lastRowNum = $rows
|
||||||
|
|
||||||
|
sql select * from $mtPrefix where t1c <= $i
|
||||||
|
if $lastRowNum != $rows then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
$i = $i + 1
|
||||||
|
endw
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
Loading…
Reference in New Issue