Uploaded image for project: 'Hibernate ORM'
  1. HHH-12469

Add support for IN-lists padding to better reuse cached statements

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.3.0.CR2, 5.2.18
    • Component/s: None
    • Labels:
      None
    • Last commented by a user?:
      true
    • Sprint:

      Description

      As described in this Twitter thread, we could add a new feature which generates power-of-2 IN lists so we get a better chance of reusing the execution plan, especially on Oracle and SQL Server.

      So, let's assume we have the following 3 SELECT queries executed:

      SELECT * FROM my_table where id IN (1, 2, 3);
      SELECT * FROM my_table where id IN (4, 6, 7);
      SELECT * FROM my_table where id IN (7, 8, 9, 10);
      

      We can rewrite them as:

      SELECT * FROM my_table where id IN (1, 2, 3, 3);
      SELECT * FROM my_table where id IN (4, 6, 7, 7);
      SELECT * FROM my_table where id IN (7, 8, 9, 10);
      

      This way we reuse the same cached statement:

      SELECT * FROM my_table where id IN (?, ?, ?, ?);
      

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: