namhnguyen / asterixdb

Automatically exported from code.google.com/p/asterixdb
0 stars 0 forks source link

spatial-intersect join doesn't use index when contained in subplan #838

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
DDL:
drop dataverse channels if exists;
create dataverse channels;
use dataverse channels;

create type TweetMessageType as closed {
  tweetid: int64,
  sender-location: point,
  text: string
}

create type TweetHistorySubscription as open{
  subscription-id: int32,
  location: point
}

create dataset TweetHistorySubscriptions(TweetHistorySubscription)
primary key subscription-id;
create index testa on TweetHistorySubscriptions(location) type rtree;

create dataset TweetMessages(TweetMessageType)
primary key tweetid;
create index locationIdx on TweetMessages(sender-location) type rtree;

create function NearbyTweetsContainingText($location, $word) {
  for $tweet in dataset TweetMessages
    let $circle := create-circle($location,30.0)
    where spatial-intersect($tweet.sender-location, $circle)
    and contains($tweet.text, $word)
    return $tweet
};

for $sub in dataset TweetHistorySubscriptions
for $text in NearbyTweetsContainingText($sub.location,$sub.word)
return {
"subscription-id":$sub.subscription-id,
"changeSet":1,
"execution-time":current-datetime(),
"message-text":$text
}

This query should be able to pick up the index for the spatial-intersect, but 
it doesn't.

Original issue reported on code.google.com by sjaco...@ucr.edu on 8 Dec 2014 at 8:36

GoogleCodeExporter commented 9 years ago
Actually there is a way to get this bug without the function. The following 
query will also ignore the index:

for $sub in dataset TweetHistorySubscriptions 
let $location := $sub.location
let $word := $sub.word
for $text in (
  for $tweet in dataset TweetMessages 
    let $circle := create-circle($location,30.0) 
    where spatial-intersect($tweet.sender-location, $circle) 
    and contains($tweet.text, $word) 
    return $tweet 
)
return { 
    "subscription-id":$sub.subscription-id, 
    "changeSet":1, 
    "execution-time":current-datetime(), 
    "message-text":$text 
}

Original comment by sjaco...@ucr.edu on 9 Dec 2014 at 9:17

GoogleCodeExporter commented 9 years ago

Original comment by sjaco...@ucr.edu on 10 Dec 2014 at 9:25

GoogleCodeExporter commented 9 years ago

Original comment by sjaco...@ucr.edu on 15 Dec 2014 at 7:06

GoogleCodeExporter commented 9 years ago
Issue 837 has been merged into this issue.

Original comment by sjaco...@ucr.edu on 17 Dec 2014 at 9:59

GoogleCodeExporter commented 9 years ago

Original comment by sjaco...@ucr.edu on 17 Dec 2014 at 10:11

GoogleCodeExporter commented 9 years ago

Original comment by sjaco...@ucr.edu on 3 Feb 2015 at 9:21