Search code examples
sqlperformancesap-ase

Tips to enhance the performance of the following simply SQL query


I would like to receive help in enhancing the performance of my SQL query. The query is so simple, but it is taking quite sometime to execute, so I would like some tips on how I can enhance the query:

  SELECT
    *
  FROM
    SOME_DB_TABLE
  WHERE
    SUBSTRING(TIME, 1, 8)
  BETWEEN
    "20110101" AND "20111231"
  AND
    CONDITION_COL = "C"
  GROUP BY
    TIME
  ORDER BY
    TIME ASC

Solution

  • The substring function could be slowing your query down.

    Would something like the below work?

    time >= "20110101" 
    and time < "20120101"