Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4994

SQL-to-RelNode conversion is slow if table contains hundreds of fields

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.30.0
    • core

    Description

      When converting from Sql To Rel, In SqlToRelConverter for every single instance of an identifier we create a new map in 

      org.apache.calcite.sql2rel.SqlToRelConverter.Blackboard#lookupExp

       

      final Map<String, Integer> fieldOffsets = new HashMap<>();
      for (RelDataTypeField f : resolve.rowType().getFieldList()) {
      if (!fieldOffsets.containsKey(f.getName())) {
      fieldOffsets.put(f.getName(), f.getIndex());
      }
      }
      final Map<String, Integer> map = ImmutableMap.copyOf(fieldOffsets);

       

      So for a Sql Query

      SELECT name, nation FROM customer

      We would do the above operation twice.

      Memoization of this information will improve performance.

      In my database, I had observed that for a large table involving 1200 columns and a huge select having multiple expressions and operators, this part was a bottleneck.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jaynarale Jay Narale
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m