OpenJPA
  1. OpenJPA
  2. OPENJPA-338

Remove unnecessary CAST in SQL statement for DB2

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0
    • Fix Version/s: 1.0.1, 1.1.0
    • Component/s: sql
    • Labels:
      None
    • Environment:
      Window XP, JDK 1.5

      Description

      There were unnecessary CAST added to the SQL statements that can be removed to improve the performance. The change will eliminate the CAST for the constants. For example, the original query is :
      Executing query: select d from DogABS d where LENGTH(d.name) < 10

      The current generated SQL statement:
      executing prepstmnt 1335250838 SELECT t0.id2, t0.datastoreid, t0.domestic, t0.name, t0.price, t0.total FROM DOGABS t0 WHERE (CAST(LENGTH(CAST(t0.name AS VARCHAR(1000))) AS BIGINT) < CAST(? AS BIGINT)) [params=(long) 10]

      After the changes:
      executing prepstmnt 1749706826 SELECT t0.id2, t0.datastoreid, t0.domestic, t0.name, t0.price, t0.total FROM DOGABS t0 WHERE (LENGTH(t0.name) < ?) [params=(long) 10]

      1. OPENJPA338-comparsion.txt
        7 kB
        Teresa Kan
      2. OPENJPA-338.patch
        3 kB
        Teresa Kan

        Activity

        Teresa Kan created issue -
        Teresa Kan made changes -
        Field Original Value New Value
        Attachment OPENJPA-338.patch [ 12364608 ]
        Teresa Kan made changes -
        Attachment OPENJPA338-comparsion.txt [ 12364609 ]
        Kevin Sutter made changes -
        Assignee Teresa Kan [ tckan1 ]
        Kevin Sutter made changes -
        Fix Version/s 1.0.1 [ 12312687 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.1.0 [ 12312344 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Michael Dick made changes -
        Fix Version/s 1.0.1 [ 12312687 ]
        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Teresa Kan
            Reporter:
            Teresa Kan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development