What steps will reproduce the problem?
1. Run the following DDLs
/*schema*/
drop dataverse STBench if exists;
create dataverse STBench;
use dataverse STBench;
/* longitude: x, latitude: y */
create type SimpleGeoPlaceType as closed {
coordinates: point, /* geometry -> coordinates (first -> should be x, second -> should be y) */
id: int64,
name: string, /* properties -> name */
tags: string, /* properties -> tags (arrary of string) */
categories: string, /* properties -> classifiers -> category, type, subcategory (will be concatenated as a string) */
phone: string /* properties -> phone */
}
create dataset SimpleGeoPlace (SimpleGeoPlaceType) primary key id;
2. Run the following query with showing the optimized query plan
use dataverse STBench;
for $x in dataset SimpleGeoPlace
where $x.id >= int64("10i64")
limit 5
return $x
What is the expected output? What do you see instead?
The optimized plan from the above query is wrong by pushing the limit operator
too far. The limit operator should be placed in between btree-search op and
sort-merge-exchange op
distribute result [%0->$$0]
-- DISTRIBUTE_RESULT |UNPARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |UNPARTITIONED|
limit AInt32: {5}
-- STREAM_LIMIT |UNPARTITIONED|
project ([$$0])
-- STREAM_PROJECT |PARTITIONED|
exchange
-- SORT_MERGE_EXCHANGE [$$5(ASC) ] |PARTITIONED|
unnest-map [$$5, $$0] <- function-call: asterix:index-search, Args:[AString: {SimpleGeoPlace}, AInt32: {0}, AString: {STBench}, AString: {SimpleGeoPlace}, ABoolean: {false}, ABoolean: {false}, ABoolean: {false}, AInt32: {1}, %0->$$7, AInt32: {0}, TRUE, TRUE, FALSE]
-- BTREE_SEARCH |PARTITIONED|
exchange
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
assign [$$7] <- [AInt64: {10}]
-- ASSIGN |PARTITIONED|
limit AInt32: {5}
-- STREAM_LIMIT |PARTITIONED|
empty-tuple-source
-- EMPTY_TUPLE_SOURCE |PARTITIONED|
Original issue reported on code.google.com by kiss...@gmail.com on 11 Jul 2015 at 12:27
Original issue reported on code.google.com by
kiss...@gmail.com
on 11 Jul 2015 at 12:27