提交 8921cc28 编写于 作者: O obdev 提交者: ob-robot

[CP] [MySQL GIS] fix spatial index coveredby keypart generation

上级 c4188df8
......@@ -9021,49 +9021,81 @@ int ObQueryRange::get_geo_coveredby_keypart(uint32_t input_srid,
query_range_ctx_->cur_expr_is_precise_ = false;
exec_ctx = query_range_ctx_->exec_ctx_;
}
ObKeyPartList and_ranges;
ObKeyPart *head = nullptr;
ObKeyPart *last = nullptr;
hash::ObHashSet<uint64_t> cellid_set;
if (OB_FAIL(cellid_set.create(128, "CoveredByKeyPart", "HashNode"))) {
LOG_WARN("failed to create cellid set", K(ret));
} else if (!cellid_set.created()) {
ret = OB_NOT_INIT;
LOG_WARN("fail to init cellid set", K(ret));
}
for (uint64_t i = 0; OB_SUCC(ret) && i < cells.size(); i++) {
ObKeyPart *head = NULL;
ObKeyPart *last = NULL;
if (OB_ISNULL((head = create_new_key_part()))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("alloc memory failed", K(ret));
} else {
ObObj val;
val.set_uint64(cells[i]);
head->id_ = out_key_part->id_;
head->pos_ = out_key_part->pos_;
if (OB_FAIL(get_geo_single_keypart(val, val, *head))) {
LOG_WARN("get normal cmp keypart failed", K(ret));
} else {
last = head;
}
}
ObS2Cellids ancestors;
if (OB_FAIL(s2object->get_ancestors(cells[i], ancestors))) {
LOG_WARN("Get ancestors of cell failed", K(ret));
}
for (uint64_t i = 0; OB_SUCC(ret) && i < ancestors.size(); i++) {
ObKeyPart *tmp = NULL;
if (OB_ISNULL((tmp = create_new_key_part()))) {
int hash_ret = cellid_set.exist_refactored(cells[i]);
if (OB_HASH_NOT_EXIST == hash_ret) {
ObKeyPart *cell_head = nullptr;
ObKeyPart *cell_last = nullptr;
if (OB_FAIL(cellid_set.set_refactored(cells[i]))) {
LOG_WARN("failed to add cellid into set", K(ret));
} else if (OB_ISNULL((cell_head = create_new_key_part()))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("alloc memory failed", K(ret));
} else {
ObObj val;
val.set_uint64(ancestors[i]);
tmp->id_ = out_key_part->id_;
tmp->pos_ = out_key_part->pos_;
if (OB_FAIL(get_geo_single_keypart(val, val, *tmp))) {
val.set_uint64(cells[i]);
cell_head->id_ = out_key_part->id_;
cell_head->pos_ = out_key_part->pos_;
if (OB_FAIL(get_geo_single_keypart(val, val, *cell_head))) {
LOG_WARN("get normal cmp keypart failed", K(ret));
} else {
last->or_next_ = tmp;
last = tmp;
cell_last = cell_head;
}
}
}
if (!and_ranges.add_last(head)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Add key part range failed", K(ret));
ObS2Cellids ancestors;
if (OB_FAIL(ret)) {
} else if (OB_FAIL(s2object->get_ancestors(cells[i], ancestors))) {
LOG_WARN("Get ancestors of cell failed", K(ret));
}
// if cur cellid is exists in set, then it's ancestors also exist in set
int hash_ret = OB_HASH_NOT_EXIST;
for (uint64_t i = 0; OB_SUCC(ret) && i < ancestors.size(); i++) {
hash_ret = cellid_set.exist_refactored(ancestors[i]);
if (hash_ret == OB_HASH_NOT_EXIST) {
ObKeyPart *tmp = NULL;
if (OB_FAIL(cellid_set.set_refactored(ancestors[i]))) {
LOG_WARN("failed to add cellid into set", K(ret));
} else if (OB_ISNULL((tmp = create_new_key_part()))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("alloc memory failed", K(ret));
} else {
ObObj val;
val.set_uint64(ancestors[i]);
tmp->id_ = out_key_part->id_;
tmp->pos_ = out_key_part->pos_;
if (OB_FAIL(get_geo_single_keypart(val, val, *tmp))) {
LOG_WARN("get normal cmp keypart failed", K(ret));
} else {
cell_last->or_next_ = tmp;
cell_last = tmp;
}
}
} else if (OB_HASH_EXIST != hash_ret) {
ret = hash_ret;
LOG_WARN("fail to check if key exist", K(ret), K(ancestors[i]), K(i));
}
}
if (OB_SUCC(ret)) {
if (OB_ISNULL(head)) {
head = cell_head;
} else {
last->or_next_ = cell_head;
}
last = cell_last;
}
} else if (OB_HASH_EXIST != hash_ret) {
ret = hash_ret;
LOG_WARN("fail to check if key exist", K(ret), K(cells[i]), K(i));
}
}
......@@ -9075,31 +9107,15 @@ int ObQueryRange::get_geo_coveredby_keypart(uint32_t input_srid,
} else {
query_range_ctx_ = new(ptr) ObQueryRangeCtx(exec_ctx, NULL, NULL);
}
ObKeyPart *temp_result = NULL;
ObS2Cellids cells_cover_geo;
ObSqlBitSet<> key_offsets;
if (OB_FAIL(ret)) {
} else if (OB_FAIL(and_range_graph(and_ranges, temp_result))) {
LOG_WARN("And query range failed", K(ret));
} else if (NULL == temp_result) {
// no range left
} else if (OB_FAIL(refine_large_range_graph(temp_result))) {
LOG_WARN("failed to refine large range graph", K(ret));
} else if (OB_FAIL(remove_useless_range_graph(temp_result, key_offsets))) {
LOG_WARN("failed to remove useless range", K(ret));
} else if (OB_FAIL(s2object->get_cellids(cells_cover_geo, false))) {
LOG_WARN("Get cellids from s2object failed", K(ret));
} else {
// get the last node
ObKeyPart *cur = temp_result;
ObKeyPart *last = NULL;
while (OB_NOT_NULL(cur)) {
last = cur;
cur = cur->or_next_;
}
for (uint64_t i = 0; OB_SUCC(ret) && i < cells_cover_geo.size(); i++) {
for (uint64_t i = 0; OB_SUCC(ret) && i < cells_cover_geo.size(); i++) {
int hash_ret = cellid_set.exist_refactored(cells_cover_geo[i]);
if (OB_HASH_NOT_EXIST == hash_ret) {
ObKeyPart *tmp = NULL;
if (OB_ISNULL((tmp = create_new_key_part()))) {
if (OB_FAIL(cellid_set.set_refactored(cells_cover_geo[i]))) {
LOG_WARN("failed to add cellid into set", K(ret));
} else if (OB_ISNULL((tmp = create_new_key_part()))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("alloc memory failed", K(ret));
} else {
......@@ -9114,24 +9130,35 @@ int ObQueryRange::get_geo_coveredby_keypart(uint32_t input_srid,
last = tmp;
}
}
} else if (OB_HASH_EXIST != hash_ret) {
ret = hash_ret;
LOG_WARN("fail to check if key exist", K(ret), K(cells_cover_geo[i]), K(i));
}
// copy temp_result to out_key_part
if (OB_FAIL(out_key_part->create_normal_key())) {
LOG_WARN("create normal key failed", K(ret));
} else if (OB_ISNULL(out_key_part->normal_keypart_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("normal keypart is null");
} else {
out_key_part->null_safe_ = temp_result->null_safe_;
out_key_part->normal_keypart_->include_start_ = true;
out_key_part->normal_keypart_->include_end_ = true;
out_key_part->normal_keypart_->start_ = temp_result->normal_keypart_->start_;
out_key_part->normal_keypart_->end_ = temp_result->normal_keypart_->end_;
out_key_part->normal_keypart_->always_false_ = false;
out_key_part->normal_keypart_->always_true_ = false;
out_key_part->item_next_ = temp_result->item_next_;
out_key_part->or_next_ = temp_result->or_next_;
out_key_part->and_next_ = temp_result->and_next_;
}
// copy temp_result to out_key_part
if (OB_FAIL(ret)) {
} else if (OB_FAIL(out_key_part->create_normal_key())) {
LOG_WARN("create normal key failed", K(ret));
} else if (OB_ISNULL(out_key_part->normal_keypart_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("normal keypart is null");
} else {
out_key_part->null_safe_ = head->null_safe_;
out_key_part->normal_keypart_->include_start_ = true;
out_key_part->normal_keypart_->include_end_ = true;
out_key_part->normal_keypart_->start_ = head->normal_keypart_->start_;
out_key_part->normal_keypart_->end_ = head->normal_keypart_->end_;
out_key_part->normal_keypart_->always_false_ = false;
out_key_part->normal_keypart_->always_true_ = false;
out_key_part->item_next_ = head->item_next_;
out_key_part->or_next_ = head->or_next_;
out_key_part->and_next_ = head->and_next_;
}
// clear hashset
if (cellid_set.created()) {
int tmp_ret = cellid_set.destroy();
if (OB_SUCC(ret) && OB_FAIL(tmp_ret)) {
LOG_WARN("failed to destory param set", K(ret));
}
}
}
......
# ----------------------------------------------------------------------
# Base test of GEOMETRY spatial index.
# ----------------------------------------------------------------------
DROP TABLE IF EXISTS t1;
create table t1(c1 int primary key, g geometry not null srid 0) partition by hash(c1) partitions 2;
create spatial index idx on t1 (g) local;
insert into t1 (c1, g) values (0, st_geomfromtext('point(1 1)'));
explain select /*+index(t1 idx)*/ st_astext(g) from t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
DROP TABLE IF EXISTS partition_t1;
create table partition_t1(c1 int primary key, g geometry not null srid 0) partition by hash(c1) partitions 2;
create spatial index idx on partition_t1 (g) local;
insert into partition_t1 (c1, g) values (0, st_geomfromtext('point(1 1)'));
explain select /*+index(partition_t1 idx)*/ st_astext(g) from partition_t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
Query Plan
=============================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-------------------------------------------------------------
|0 |PX COORDINATOR | |1 |291 |
|1 |└─EXCHANGE OUT DISTR |:EX10000|1 |291 |
|2 | └─PX PARTITION ITERATOR| |1 |289 |
|3 | └─TABLE FULL SCAN |t1(idx) |1 |289 |
=============================================================
======================================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
----------------------------------------------------------------------
|0 |PX COORDINATOR | |1 |291 |
|1 |└─EXCHANGE OUT DISTR |:EX10000 |1 |291 |
|2 | └─PX PARTITION ITERATOR| |1 |289 |
|3 | └─TABLE FULL SCAN |partition_t1(idx)|1 |289 |
======================================================================
Outputs & filters:
-------------------------------------
0 - output([INTERNAL_FUNCTION(st_astext(t1.g))]), filter(nil)
1 - output([INTERNAL_FUNCTION(st_astext(t1.g))]), filter(nil)
0 - output([INTERNAL_FUNCTION(st_astext(partition_t1.g))]), filter(nil)
1 - output([INTERNAL_FUNCTION(st_astext(partition_t1.g))]), filter(nil)
dop=1
2 - output([t1.g]), filter(nil)
2 - output([partition_t1.g]), filter(nil)
force partition granule
3 - output([t1.g]), filter([st_intersects(t1.g, st_geomfromtext('point(1 1)'))])
access([t1.c1], [t1.g]), partitions(p[0-1])
3 - output([partition_t1.g]), filter([st_intersects(partition_t1.g, st_geomfromtext('point(1 1)'))])
access([partition_t1.c1], [partition_t1.g]), partitions(p[0-1])
is_index_back=true, is_global_index=false, filter_before_indexback[false],
range_key([t1.__cellid_17], [t1.__mbr_17], [t1.c1]), range(1152921504606846977,MIN,MIN ; 1152921504606846977,MAX,MAX), (1152921504606846980,MIN,MIN
; 1152921504606846980,MAX,MAX), (1152921504606846992,MIN,MIN ; 1152921504606846992,MAX,MAX), (1152921504606847040,MIN,MIN ; 1152921504606847040,MAX,MAX),
(1152921504606847232,MIN,MIN ; 1152921504606847232,MAX,MAX), (1152921504606848000,MIN,MIN ; 1152921504606848000,MAX,MAX), (1152921504606851072,MIN,MIN
; 1152921504606851072,MAX,MAX), (1152921504606863360,MIN,MIN ; 1152921504606863360,MAX,MAX), (1152921504606912512,MIN,MIN ; 1152921504606912512,MAX,MAX),
(1152921504607109120,MIN,MIN ; 1152921504607109120,MAX,MAX), (1152921504607895552,MIN,MIN ; 1152921504607895552,MAX,MAX), (1152921504611041280,MIN,MIN
; 1152921504611041280,MAX,MAX), (1152921504623624192,MIN,MIN ; 1152921504623624192,MAX,MAX), (1152921504673955840,MIN,MIN ; 1152921504673955840,MAX,MAX),
(1152921504875282432,MIN,MIN ; 1152921504875282432,MAX,MAX), (1152921505680588800,MIN,MIN ; 1152921505680588800,MAX,MAX), (1152921508901814272,MIN,MIN
; 1152921508901814272,MAX,MAX), (1152921521786716160,MIN,MIN ; 1152921521786716160,MAX,MAX), (1152921573326323712,MIN,MIN ; 1152921573326323712,MAX,MAX),
(1152921779484753920,MIN,MIN ; 1152921779484753920,MAX,MAX), (1152922604118474752,MIN,MIN ; 1152922604118474752,MAX,MAX), (1152925902653358080,MIN,MIN
; 1152925902653358080,MAX,MAX), (1152939096792891392,MIN,MIN ; 1152939096792891392,MAX,MAX), (1152991873351024640,MIN,MIN ; 1152991873351024640,MAX,MAX),
(1153202979583557632,MIN,MIN ; 1153202979583557632,MAX,MAX), (1154047404513689600,MIN,MIN ; 1154047404513689600,MAX,MAX), (1157425104234217472,MIN,MIN
; 1157425104234217472,MAX,MAX), (1170935903116328960,MIN,MIN ; 1170935903116328960,MAX,MAX), (1224979098644774912,MIN,MIN ; 1224979098644774912,MAX,MAX),
(1441151880758558720,MIN,MIN ; 1441151880758558720,MAX,MAX), (1152921504606846976,MIN,MIN ; 1152921504606846976,MAX,MAX)
select /*+index(t1 idx)*/ st_astext(g) from t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
range_key([partition_t1.__cellid_17], [partition_t1.__mbr_17], [partition_t1.c1]), range(1152921504606846977,MIN,MIN ; 1152921504606846977,MAX,MAX),
(1152921504606846980,MIN,MIN ; 1152921504606846980,MAX,MAX), (1152921504606846992,MIN,MIN ; 1152921504606846992,MAX,MAX), (1152921504606847040,MIN,MIN
; 1152921504606847040,MAX,MAX), (1152921504606847232,MIN,MIN ; 1152921504606847232,MAX,MAX), (1152921504606848000,MIN,MIN ; 1152921504606848000,MAX,MAX),
(1152921504606851072,MIN,MIN ; 1152921504606851072,MAX,MAX), (1152921504606863360,MIN,MIN ; 1152921504606863360,MAX,MAX), (1152921504606912512,MIN,MIN
; 1152921504606912512,MAX,MAX), (1152921504607109120,MIN,MIN ; 1152921504607109120,MAX,MAX), (1152921504607895552,MIN,MIN ; 1152921504607895552,MAX,MAX),
(1152921504611041280,MIN,MIN ; 1152921504611041280,MAX,MAX), (1152921504623624192,MIN,MIN ; 1152921504623624192,MAX,MAX), (1152921504673955840,MIN,MIN
; 1152921504673955840,MAX,MAX), (1152921504875282432,MIN,MIN ; 1152921504875282432,MAX,MAX), (1152921505680588800,MIN,MIN ; 1152921505680588800,MAX,MAX),
(1152921508901814272,MIN,MIN ; 1152921508901814272,MAX,MAX), (1152921521786716160,MIN,MIN ; 1152921521786716160,MAX,MAX), (1152921573326323712,MIN,MIN
; 1152921573326323712,MAX,MAX), (1152921779484753920,MIN,MIN ; 1152921779484753920,MAX,MAX), (1152922604118474752,MIN,MIN ; 1152922604118474752,MAX,MAX),
(1152925902653358080,MIN,MIN ; 1152925902653358080,MAX,MAX), (1152939096792891392,MIN,MIN ; 1152939096792891392,MAX,MAX), (1152991873351024640,MIN,MIN
; 1152991873351024640,MAX,MAX), (1153202979583557632,MIN,MIN ; 1153202979583557632,MAX,MAX), (1154047404513689600,MIN,MIN ; 1154047404513689600,MAX,MAX),
(1157425104234217472,MIN,MIN ; 1157425104234217472,MAX,MAX), (1170935903116328960,MIN,MIN ; 1170935903116328960,MAX,MAX), (1224979098644774912,MIN,MIN
; 1224979098644774912,MAX,MAX), (1441151880758558720,MIN,MIN ; 1441151880758558720,MAX,MAX), (1152921504606846976,MIN,MIN ; 1152921504606846976,MAX,MAX)
select /*+index(partition_t1 idx)*/ st_astext(g) from partition_t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
st_astext(g)
POINT(1 1)
drop table t1;
drop table partition_t1;
DROP TABLE IF EXISTS t1;
create table t1(c1 int primary key, g geometry not null srid 0) partition by range(c1) ( partition p0 values less than (4),
partition p1 values less than (10));
......
......@@ -312,19 +312,19 @@ INSERT INTO t (g) VALUES
(ST_GeomFromText('MULTIPOLYGON (((0 0, 2 0, 2 2, 0 2, 0 0)), ((2.5 2.5, 6 2.5, 6 6, 2.5 6, 2.5 2.5), (3.5 3, 4.5 3, 4.5 4.5, 3.5 4.5, 3.5 3)))')),
(ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(2 2,3 3))'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('POINT(0 0)'));
select st_astext(g) from t where _st_covers(ST_GeomFromText('POINT(0 0)'), g);
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('POINT(1 1)'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('POINT(2 2)'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('POINT(3 3)'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('POINT(4 4)'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('POINT(5 5)'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('LINESTRING(0 0,1 1)'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('POLYGON((0 0, 10 0, 10 5, 0 5, 0 0))'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('MULTIPOINT((0 0), (1 1))'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('MULTILINESTRING((0 0, 1 1), (4 4, 5 5))'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('MULTIPOLYGON (((0 0, 2 0, 2 2, 0 2, 0 0)), ((2.5 2.5, 6 2.5, 6 6, 2.5 6, 2.5 2.5), (3.5 3, 4.5 3, 4.5 4.5, 3.5 4.5, 3.5 3)))'));
select st_astext(g) from t where _st_covers(g, ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(2 2,3 3))'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('POINT(0 0)'));
select st_astext(g) from t ignore index(idx) where _st_covers(ST_GeomFromText('POINT(0 0)'), g);
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('POINT(1 1)'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('POINT(2 2)'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('POINT(3 3)'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('POINT(4 4)'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('POINT(5 5)'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('LINESTRING(0 0,1 1)'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('POLYGON((0 0, 10 0, 10 5, 0 5, 0 0))'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('MULTIPOINT((0 0), (1 1))'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('MULTILINESTRING((0 0, 1 1), (4 4, 5 5))'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('MULTIPOLYGON (((0 0, 2 0, 2 2, 0 2, 0 0)), ((2.5 2.5, 6 2.5, 6 6, 2.5 6, 2.5 2.5), (3.5 3, 4.5 3, 4.5 4.5, 3.5 4.5, 3.5 3)))'));
select st_astext(g) from t ignore index(idx) where _st_covers(g, ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(2 2,3 3))'));
select /*+index(t idx)*/ st_astext(g) from t where _st_covers(g, ST_GeomFromText('POINT(0 0)'));
......@@ -487,4 +487,26 @@ select id, st_astext(g) from geo_t1 FORCE INDEX(g_idx) where st_within(g, ST_Geo
select id, st_astext(g) from geo_t1 IGNORE INDEX(g_idx) where _st_covers(ST_GeomFromText('POLYGON((0 0, 10 0, 10 5, 0 5, 0 0))', 4326, 'axis-order=long-lat'), g);
select id, st_astext(g) from geo_t1 FORCE INDEX(g_idx) where _st_covers(ST_GeomFromText('POLYGON((0 0, 10 0, 10 5, 0 5, 0 0))', 4326, 'axis-order=long-lat'), g);
drop table geo_t1;
\ No newline at end of file
drop table geo_t1;
--echo bugfix: 53822176
--disable_warnings
drop table if exists spatial_point_in_line;
--enable_warnings
create table spatial_point_in_line (
`id` int unsigned not null auto_increment primary key ,
`min` int unsigned not null default 0,
`max` int unsigned not null default 0,
`line_geo` geometry not null srid 0,
SPATIAL INDEX index_spatial_line_geo(`line_geo`)
);
insert into spatial_point_in_line (min, max, line_geo) values
(80, 90, LineString(Point(min, 0), Point(max, 0))),
(80, 100, LineString(Point(min, 0), Point(max, 0))),
(90, 100, LineString(Point(min, 0), Point(max, 0))),
(100, 110, LineString(Point(min, 0), Point(max, 0))),
(100, 120, LineString(Point(min, 0), Point(max, 0)));
select id, min, max, st_astext(line_geo) from spatial_point_in_line where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
explain select id, min, max, st_astext(line_geo) from spatial_point_in_line where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
select id, min, max, st_astext(line_geo) from spatial_point_in_line ignore index(geom_idx_1) where ST_Contains(line_geo, LineString(Point(80, 0), Point(91, 0)));
......@@ -6,14 +6,14 @@
--source mysql_test/test_suite/geometry/t/import_default_srs_data_mysql.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS partition_t1;
--enable_warnings
create table t1(c1 int primary key, g geometry not null srid 0) partition by hash(c1) partitions 2;
create spatial index idx on t1 (g) local;
insert into t1 (c1, g) values (0, st_geomfromtext('point(1 1)'));
explain select /*+index(t1 idx)*/ st_astext(g) from t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
select /*+index(t1 idx)*/ st_astext(g) from t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
drop table t1;
create table partition_t1(c1 int primary key, g geometry not null srid 0) partition by hash(c1) partitions 2;
create spatial index idx on partition_t1 (g) local;
insert into partition_t1 (c1, g) values (0, st_geomfromtext('point(1 1)'));
explain select /*+index(partition_t1 idx)*/ st_astext(g) from partition_t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
select /*+index(partition_t1 idx)*/ st_astext(g) from partition_t1 where st_intersects(g, st_geomfromtext('point(1 1)'));
drop table partition_t1;
--disable_warnings
DROP TABLE IF EXISTS t1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册