Mostafa Mokhtar created IMPALA-7020:
---------------------------------------

             Summary: Order by expressions in Analytical functions are not 
materialized causing severe slow down
                 Key: IMPALA-7020
                 URL: https://issues.apache.org/jira/browse/IMPALA-7020
             Project: IMPALA
          Issue Type: Bug
          Components: Frontend
    Affects Versions: Impala 2.12.0
            Reporter: Mostafa Mokhtar
         Attachments: Slow case profile.txt, Workaround profile.txt

Order by expressions in Analytical functions are not materialized and cause 
queries to run much slower.

The rewrite for the query below is 20x faster, profiles attached.

Repro 
{code}
select *
FROM
  (
    SELECT
      o.*,
      ROW_NUMBER() OVER(ORDER BY evt_ts DESC) AS rn
    FROM
      (
        SELECT
          l_orderkey,l_partkey,l_linenumber,l_quantity, cast (l_shipdate as 
string) evt_ts
        FROM
          lineitem
        WHERE
          l_shipdate  BETWEEN '1992-01-01 00:00:00' AND '1992-01-15 00:00:00'
      ) o
  ) r
WHERE
  rn BETWEEN 1 AND 101
ORDER BY rn;
{code}

Workaround 
{code}
select *
FROM
  (
    SELECT
      o.*,
      ROW_NUMBER() OVER(ORDER BY evt_ts DESC) AS rn
    FROM
      (
        SELECT
          l_orderkey,l_partkey,l_linenumber,l_quantity, cast (l_shipdate as 
string) evt_ts
        FROM
          lineitem
        WHERE
          l_shipdate  BETWEEN '1992-01-01 00:00:00' AND '1992-01-15 00:00:00'
          union all 
                  SELECT
          l_orderkey,l_partkey,l_linenumber,l_quantity, cast (l_shipdate as 
string) evt_ts
        FROM
          lineitem limit 0
        
      ) o
  ) r
WHERE
  rn BETWEEN 1 AND 101
ORDER BY rn;
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org
For additional commands, e-mail: issues-all-h...@impala.apache.org

Reply via email to