asterixdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (ASTERIXDB-1073) Use an index for comparing datetime to current-datetime()
Date Mon, 14 Sep 2015 17:45:45 GMT

     [ https://issues.apache.org/jira/browse/ASTERIXDB-1073?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Till Westmann updated ASTERIXDB-1073:
-------------------------------------
    Component/s: Optimizer
                 AsterixDB

> Use an index for comparing datetime to current-datetime()
> ---------------------------------------------------------
>
>                 Key: ASTERIXDB-1073
>                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1073
>             Project: Apache AsterixDB
>          Issue Type: Improvement
>          Components: AsterixDB, Optimizer
>            Reporter: Steven Jacobs
>            Assignee: Steven Jacobs
>
> Using the following DDL:
> drop dataverse emergencyTest if exists;
> create dataverse emergencyTest;
> use dataverse emergencyTest;
> create type CHPReport as {
> 	"id":int,
> 	"timestamp":datetime
> }
> create dataset CHPReports(CHPReport)
> primary key timestamp;
> This query will use an index search:
> for $emergency in dataset CHPReports
> where $emergency.timestamp >= datetime("2012-08-07T10:10:00.000Z")
> return $emergency.message;
> Whereas this will do a data scan:
> for $emergency in dataset CHPReports
> where $emergency.timestamp >= current-datetime()
> return $emergency.message;
> Both are build on BTREEs so both should be optimized to an index search. It seems like
there should be a way to use the index when comparing to current-datetime, Although I suspect
the solution is nontrivial because of the way that current-datetime is currently working.
> Here are the plans, respectively:
> distribute result [%0->$$5]
> -- DISTRIBUTE_RESULT  |PARTITIONED|
>   exchange 
>   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
>     project ([$$5])
>     -- STREAM_PROJECT  |PARTITIONED|
>       assign [$$5] <- [function-call: asterix:field-access-by-name, Args:[%0->$$0,
AString: {message}]]
>       -- ASSIGN  |PARTITIONED|
>         project ([$$0])
>         -- STREAM_PROJECT  |PARTITIONED|
>           exchange 
>           -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
>             unnest-map [$$6, $$0] <- function-call: asterix:index-search, Args:[AString:
{CHPReports}, AInt32: {0}, AString: {emergencyTest}, AString: {CHPReports}, ABoolean: {false},
ABoolean: {false}, ABoolean: {false}, AInt32: {1}, %0->$$8, AInt32: {0}, TRUE, TRUE, FALSE]
>             -- BTREE_SEARCH  |PARTITIONED|
>               exchange 
>               -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
>                 assign [$$8] <- [ADateTime: { 2012-08-07T10:10:00.000Z }]
>                 -- ASSIGN  |PARTITIONED|
>                   empty-tuple-source
>                   -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
> distribute result [%0->$$5]
> -- DISTRIBUTE_RESULT  |PARTITIONED|
>   exchange 
>   -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
>     project ([$$5])
>     -- STREAM_PROJECT  |PARTITIONED|
>       assign [$$5] <- [function-call: asterix:field-access-by-name, Args:[%0->$$0,
AString: {message}]]
>       -- ASSIGN  |PARTITIONED|
>         project ([$$0])
>         -- STREAM_PROJECT  |PARTITIONED|
>           select (function-call: algebricks:ge, Args:[%0->$$6, function-call: asterix:current-datetime,
Args:[]])
>           -- STREAM_SELECT  |PARTITIONED|
>             exchange 
>             -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
>               data-scan []<-[$$6, $$0] <- emergencyTest:CHPReports
>               -- DATASOURCE_SCAN  |PARTITIONED|
>                 exchange 
>                 -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
>                   empty-tuple-source
>                   -- EMPTY_TUPLE_SOURCE  |PARTITIONED|



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message