Skip to content

CAST function is not calculated at compile time which prevents usage of index/metadata #8534

@richardstartin

Description

@richardstartin

This query

select count(*) from complexWebsite where hoursSinceEpoch > cast(0.0 as long)
"timeUsedMs": 341,
"numEntriesScannedInFilter": 7500000
BROKER_REDUCE(limit:10) 
COMBINE_AGGREGATE 
AGGREGATE(aggregations:count(*))
TRANSFORM_PASSTHROUGH()
PROJECT()
DOC_ID_SET
FILTER_EXPRESSION(operator:RANGE,predicate:minus(hoursSinceEpoch,cast('0.0','long')) > '0')

is much slower than

select count(*) from complexWebsite where hoursSinceEpoch > 0
"timeUsedMs": 3,
"numEntriesScannedInFilter": 0
BROKER_REDUCE(limit:10) 
COMBINE_AGGREGATE 
FAST_FILTERED_COUNT 
FILTER_MATCH_ENTIRE_SEGMENT(docs:7500000)

Because cast is not calculated at compile time. This results in the slow query not using metadata, because it doesn't know whether the function is volatile or constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions