Skip to content

[Doris on ES] unix_timestamp(date_format(now(), '%Y-%m-%d')) not push down #3559

@BabySid

Description

@BabySid

Describe the bug

I found a slow query:

select k1 from mytable where Updatetime < unix_timestamp(date_format(now(), '%Y-%m-%d')) ;

It costs more than 5s.

The log in be.INFO is

{"query":{"match_all":{}},"stored_fields":"_none_","docvalue_fields":["k1","UpdateTime"],"sort":["_doc"],"size":4096}

i used another sql with the same meaning:

select k1 from mytable where Updatetime < 1589212800;

it costs less then 1s.

The log in be.INFO is

 {"query":{"bool":{"filter":[{"bool":{"should":[{"range":{"UpdateTime":{"lt":"1589212800"}}}]}}]}},"stored_fields":"_none_","docvalue_fields":["k1","UpdateTime"],"sort":["_doc"],"size":4096}

I suspect that these basic functions (e.g. unix_timestamp(date_format(now(), '%Y-%m-%d'))) are not precomputed.

Version: Master

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/sqlIssues or PRs related to SQLkind/fixCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions