Not optimal sql query

XMLWordPrintable

    • Type: Incident report
    • Resolution: Unsupported version
    • Priority: Trivial
    • None
    • Affects Version/s: 2.4.7rc1
    • Component/s: Frontend (F)
    • Environment:
      Oracle DB

      In frontend I found not optimal sql query for Oracle.
      SELECT * FROM (SELECT FROM history_uint h WHERE h.itemid='373778' ORDER BY h.clock DESC) WHERE rownum BETWEEN 0 AND 1
      This is too slow.(~300sec on my db)

      I applied the workaround.
      SELECT * FROM history_uint h WHERE h.itemid='373778' and h.clock = (SELECT max(h2.clock) FROM history_uint h2 WHERE h2.itemid='373778')
      This query executed about 0.5-2 sec.

            Assignee:
            Unassigned
            Reporter:
            Andrey Dudin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: