[CP] enable storage row estimate for gis index with more than 10 ranges

This commit is contained in:
obdev 2024-03-12 03:53:04 +00:00 committed by ob-robot
parent 4af9637abb
commit 1f7c8640f5
6 changed files with 485 additions and 278 deletions

View File

@ -35,13 +35,41 @@ int ObAccessPathEstimation::estimate_rowcount(ObOptimizerContext &ctx,
ObBaseTableEstMethod &method)
{
int ret = OB_SUCCESS;
ObBaseTableEstMethod valid_methods = 0;
method = EST_INVALID;
ObSEArray<AccessPath *, 4> normal_paths;
ObSEArray<AccessPath *, 4> geo_paths;
ObBaseTableEstMethod geo_method;
if (OB_UNLIKELY(paths.empty())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(ret));
} else if (OB_FAIL(get_valid_est_methods(ctx, paths, filter_exprs, is_inner_path, valid_methods))) {
} else if (is_inner_path) {
if (OB_FAIL(inner_estimate_rowcount(ctx, paths, is_inner_path, filter_exprs, method))) {
LOG_WARN("failed to do estimate rowcount for paths", K(ret));
}
} else if (OB_FAIL(classify_paths(paths, normal_paths, geo_paths))) {
LOG_WARN("failed to classify paths", K(ret));
} else if (!normal_paths.empty() &&
OB_FAIL(inner_estimate_rowcount(ctx, normal_paths, is_inner_path, filter_exprs, method))) {
LOG_WARN("failed to do estimate rowcount for normal paths", K(ret));
} else if (!geo_paths.empty() &&
OB_FAIL(inner_estimate_rowcount(ctx, geo_paths, is_inner_path, filter_exprs, geo_method))) {
LOG_WARN("failed to do estimate rowcount for geo paths", K(ret));
} else if (normal_paths.empty() && !geo_paths.empty()) {
method = geo_method;
}
return ret;
}
int ObAccessPathEstimation::inner_estimate_rowcount(ObOptimizerContext &ctx,
common::ObIArray<AccessPath *> &paths,
const bool is_inner_path,
const ObIArray<ObRawExpr*> &filter_exprs,
ObBaseTableEstMethod &method)
{
int ret = OB_SUCCESS;
ObBaseTableEstMethod valid_methods = 0;
method = EST_INVALID;
if (OB_FAIL(get_valid_est_methods(ctx, paths, filter_exprs, is_inner_path, valid_methods))) {
LOG_WARN("failed to get valid est methods", K(ret));
} else if (OB_FAIL(choose_best_est_method(ctx, paths, filter_exprs, valid_methods, method))) {
LOG_WARN("failed to choose one est method", K(ret), K(valid_methods));
@ -400,7 +428,7 @@ int ObAccessPathEstimation::check_path_can_use_storage_estimation(const AccessPa
int64_t partition_count = part_info->get_phy_tbl_location_info().get_partition_cnt();
if (partition_count > 1 ||
scan_range_count <= 0 ||
scan_range_count > ObOptEstCost::MAX_STORAGE_RANGE_ESTIMATION_NUM) {
(!path->est_cost_info_.index_meta_info_.is_geo_index_ && scan_range_count > ObOptEstCost::MAX_STORAGE_RANGE_ESTIMATION_NUM)) {
can_use = false;
} else {
can_use = true;
@ -2061,5 +2089,25 @@ bool ObAccessPathEstimation::is_retry_ret(int ret)
ret == OB_TABLET_NOT_EXIST;
}
int ObAccessPathEstimation::classify_paths(ObIArray<AccessPath *> &paths,
ObIArray<AccessPath *> &normal_paths,
ObIArray<AccessPath *> &geo_paths)
{
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < paths.count(); ++i) {
if (OB_ISNULL(paths.at(i))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get null path", K(ret));
} else if (paths.at(i)->est_cost_info_.index_meta_info_.is_geo_index_) {
if (OB_FAIL(geo_paths.push_back(paths.at(i)))) {
LOG_WARN("failed to push back geo path", K(ret));
}
} else if (OB_FAIL(normal_paths.push_back(paths.at(i)))) {
LOG_WARN("failed to push back normal path", K(ret));
}
}
return ret;
}
} // end of sql
} // end of oceanbase

View File

@ -55,6 +55,12 @@ public:
uint64_t ref_table_id,
bool &can_use);
private:
static int inner_estimate_rowcount(ObOptimizerContext &ctx,
common::ObIArray<AccessPath *> &paths,
const bool is_inner_path,
const ObIArray<ObRawExpr*> &filter_exprs,
ObBaseTableEstMethod &method);
static inline uint64_t choose_one_est_method(ObBaseTableEstMethod valid_methods, const ObBaseTableEstMethod est_priority[], uint64_t cnt)
{
ObBaseTableEstMethod ret = EST_INVALID;
@ -238,6 +244,9 @@ private:
ObIArray<AccessPath *> &paths,
const bool is_inner_path,
ObIArray<ObDSResultItem> &ds_result_items);
static int classify_paths(common::ObIArray<AccessPath *> &paths,
common::ObIArray<AccessPath *> &normal_paths,
common::ObIArray<AccessPath *> &geo_paths);
};
}

View File

@ -389,7 +389,7 @@ Query Plan
=====================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-----------------------------------------------------
|0 |TABLE FULL SCAN|tt1(idx05)|1 |299 |
|0 |TABLE FULL SCAN|tt1(idx05)|1 |159 |
=====================================================
Outputs & filters:
-------------------------------------
@ -583,3 +583,94 @@ SELECT ST_ASTEXT(B) FROM FF01 WHERE B NOT IN (SELECT /*+no_unnest*/B FROM FF01 W
ST_ASTEXT(B)
POINT(-1 -2)
drop table FF01;
drop table if exists geek_poi_7;
CREATE TABLE `geek_poi_7` (
`p_id` bigint(20) NOT NULL COMMENT 'poi id',
`p_name` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '场景名称',
`p_branch_name` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '分店名称',
`p_phone1` varchar(20) NOT NULL DEFAULT '\'\'' COMMENT '联系电话1',
`p_phone2` varchar(20) NOT NULL DEFAULT '\'\'' COMMENT '联系电话2',
`p_logo_url` longtext NOT NULL COMMENT '场景LOGO URL',
`p_scene_url` longtext NOT NULL COMMENT '场景主页URL',
`p_quickapp_url` longtext NOT NULL COMMENT '快应用场景主页URL',
`p_service_list` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '服务列表,json数组',
`c_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '分类ID',
`p_radius` double NOT NULL DEFAULT '0' COMMENT '半径大小,单位 m',
`p_province` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '省',
`p_city` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '市',
`p_district` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '区县',
`p_address` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '详细地址',
`p_longitude` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '经度',
`p_latitude` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '纬度',
`p_altitude` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '海拔高度',
`p_baidu_id` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '百度城市ID',
`p_parent_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '父级poi id',
`p_parent_list` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '父级poi 列表',
`pn_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '合作方ID,默认为 0 - 梦享网络',
`pb_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '品牌id',
`p_order` bigint(20) NOT NULL DEFAULT '0' COMMENT '排序次序',
`p_coordinate` bigint(20) NOT NULL DEFAULT '0' COMMENT '坐标系 0 - WGS84 # 1 - GCJ02 # 2 - BD09',
`p_category_list` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT 'poi 分类ID列表',
`geohash_code` varchar(20) NOT NULL DEFAULT '\'\'' COMMENT 'geog_poi 转换为 geohash 的值',
`p_create_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
`p_update_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
`p_delete_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
`p_encryption_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'POI 加密ID',
`p_class` bigint(20) NOT NULL DEFAULT '0' COMMENT '场景等级',
`p_config` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '配置项,JSON对象',
`p_tags_id` json NOT NULL COMMENT '标签列表',
`geog_poi` geometry NOT NULL /*!80003 SRID 4326 */ COMMENT '经纬度转换后的WGS84坐标对应的geography数据',
PRIMARY KEY (`p_id`),
SPATIAL KEY `idx_geohash_code_geog_poi_7` (`geog_poi`) BLOCK_SIZE 16384 LOCAL,
KEY `idx_poi_del_time_7` (`p_delete_time`) BLOCK_SIZE 16384 LOCAL
);
explain EXTENDED_NOADDR SELECT p.p_id,0 as distance FROM geek_poi_7 as p WHERE p.geohash_code like 'ws0emp%' and p.p_delete_time = 0 AND ST_Contains(p.geog_poi,_ST_GeogFromText('POINT(113.42416381835938 23.11138916015625)'));
Query Plan
===============================================
|ID|OPERATOR |NAME|EST.ROWS|EST.TIME(us)|
-----------------------------------------------
|0 |TABLE FULL SCAN|p |64 |2813 |
===============================================
Outputs & filters:
-------------------------------------
0 - output([p.p_id], [0]), filter([p.p_delete_time = 0], [(T_OP_LIKE, p.geohash_code, 'ws0emp%', '\\')], [BOOL(ST_Contains(p.geog_poi, _ST_GeogFromText('POINT(113.42416381835938
23.11138916015625)')))])
access([p.p_id], [p.geog_poi], [p.geohash_code], [p.p_delete_time]), partitions(p0)
is_index_back=false, is_global_index=false, filter_before_indexback[false,false,false],
range_key([p.p_id]), range(MIN ; MAX)always true
Used Hint:
-------------------------------------
/*+
*/
Qb name trace:
-------------------------------------
stmt_id:0, stmt_type:T_EXPLAIN
stmt_id:1, SEL$1
Outline Data:
-------------------------------------
/*+
BEGIN_OUTLINE_DATA
FULL(@"SEL$1" "p"@"SEL$1")
OPTIMIZER_FEATURES_ENABLE('')
END_OUTLINE_DATA
*/
Optimization Info:
-------------------------------------
p:
table_rows:10002
physical_range_rows:10002
logical_range_rows:10002
index_back_rows:0
output_rows:1
table_dop:1
dop_method:Table DOP
avaiable_index_name:[idx_geohash_code_geog_poi_7, idx_poi_del_time_7, geek_poi_7]
pruned_index_name:[idx_geohash_code_geog_poi_7]
stats version:0
dynamic sampling level:0
estimation method:[DEFAULT, STORAGE]
Plan Type:
LOCAL
Note:
Degree of Parallelisim is 1 because of table property

View File

@ -540,7 +540,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -565,7 +565,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -590,7 +590,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -615,7 +615,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -640,7 +640,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -665,7 +665,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -690,7 +690,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -715,7 +715,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -740,7 +740,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |304 |
=================================================
Outputs & filters:
-------------------------------------
@ -765,7 +765,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |304 |
=================================================
Outputs & filters:
-------------------------------------
@ -790,7 +790,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |304 |
=================================================
Outputs & filters:
-------------------------------------
@ -815,7 +815,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |304 |
=================================================
Outputs & filters:
-------------------------------------
@ -840,7 +840,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -865,7 +865,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |478 |
=================================================
Outputs & filters:
-------------------------------------
@ -947,7 +947,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -972,7 +972,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -997,7 +997,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1022,7 +1022,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1047,7 +1047,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1072,7 +1072,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1097,7 +1097,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1122,7 +1122,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1147,7 +1147,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1172,7 +1172,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1197,7 +1197,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1222,7 +1222,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |218 |
=================================================
Outputs & filters:
-------------------------------------
@ -1247,7 +1247,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |159 |
=================================================
Outputs & filters:
-------------------------------------
@ -1272,7 +1272,7 @@ Query Plan
=================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------
|0 |TABLE FULL SCAN|t(idx)|1 |299 |
|0 |TABLE FULL SCAN|t(idx)|1 |159 |
=================================================
Outputs & filters:
-------------------------------------

View File

@ -357,3 +357,62 @@ INSERT INTO FF01 VALUES (2,POINT(1,2));
INSERT INTO FF01 VALUES (3,POINT(-1,-2));
SELECT ST_ASTEXT(B) FROM FF01 WHERE B NOT IN (SELECT /*+no_unnest*/B FROM FF01 WHERE B=POINT(1,2));
drop table FF01;
--disable_warnings
drop table if exists geek_poi_7;
--enable_warnings
CREATE TABLE `geek_poi_7` (
`p_id` bigint(20) NOT NULL COMMENT 'poi id',
`p_name` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '场景名称',
`p_branch_name` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '分店名称',
`p_phone1` varchar(20) NOT NULL DEFAULT '\'\'' COMMENT '联系电话1',
`p_phone2` varchar(20) NOT NULL DEFAULT '\'\'' COMMENT '联系电话2',
`p_logo_url` longtext NOT NULL COMMENT '场景LOGO URL',
`p_scene_url` longtext NOT NULL COMMENT '场景主页URL',
`p_quickapp_url` longtext NOT NULL COMMENT '快应用场景主页URL',
`p_service_list` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '服务列表,json数组',
`c_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '分类ID',
`p_radius` double NOT NULL DEFAULT '0' COMMENT '半径大小,单位 m',
`p_province` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '省',
`p_city` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '市',
`p_district` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '区县',
`p_address` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '详细地址',
`p_longitude` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '经度',
`p_latitude` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '纬度',
`p_altitude` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '海拔高度',
`p_baidu_id` varchar(45) NOT NULL DEFAULT '\'\'' COMMENT '百度城市ID',
`p_parent_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '父级poi id',
`p_parent_list` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '父级poi 列表',
`pn_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '合作方ID,默认为 0 - 梦享网络',
`pb_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '品牌id',
`p_order` bigint(20) NOT NULL DEFAULT '0' COMMENT '排序次序',
`p_coordinate` bigint(20) NOT NULL DEFAULT '0' COMMENT '坐标系 0 - WGS84 # 1 - GCJ02 # 2 - BD09',
`p_category_list` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT 'poi 分类ID列表',
`geohash_code` varchar(20) NOT NULL DEFAULT '\'\'' COMMENT 'geog_poi 转换为 geohash 的值',
`p_create_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '创建时间',
`p_update_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '更新时间',
`p_delete_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '删除时间',
`p_encryption_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'POI 加密ID',
`p_class` bigint(20) NOT NULL DEFAULT '0' COMMENT '场景等级',
`p_config` varchar(255) NOT NULL DEFAULT '\'\'' COMMENT '配置项,JSON对象',
`p_tags_id` json NOT NULL COMMENT '标签列表',
`geog_poi` geometry NOT NULL /*!80003 SRID 4326 */ COMMENT '经纬度转换后的WGS84坐标对应的geography数据',
PRIMARY KEY (`p_id`),
SPATIAL KEY `idx_geohash_code_geog_poi_7` (`geog_poi`) BLOCK_SIZE 16384 LOCAL,
KEY `idx_poi_del_time_7` (`p_delete_time`) BLOCK_SIZE 16384 LOCAL
);
--disable_query_log
--disable_result_log
insert into geek_poi_7(p_id, p_logo_url,p_scene_url,p_quickapp_url, p_tags_id,geog_poi,p_delete_time) values(0, 'aaa','aaa','aaa','[]', st_geomfromtext('POINT(23.11138916015625 113.42416381835938)', 4326), 0);
let $i = 1;
while ($i <= 10000)
{
eval insert into geek_poi_7(p_id, p_logo_url,p_scene_url,p_quickapp_url, p_tags_id,geog_poi,p_delete_time) values($i, 'aaa','aaa','aaa','[]', st_geomfromtext('POINT(33.11138916015625 123.42416381835938)', 4326), $i%2);
inc $i;
}
--enable_query_log
--enable_result_log
explain EXTENDED_NOADDR SELECT p.p_id,0 as distance FROM geek_poi_7 as p WHERE p.geohash_code like 'ws0emp%' and p.p_delete_time = 0 AND ST_Contains(p.geog_poi,_ST_GeogFromText('POINT(113.42416381835938 23.11138916015625)'));