forked from apache/calcite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CALCITE-4994] SQL-to-RelNode conversion is slow if table contains hu…
…ndreds of fields If a table contains hundreds or thousands of fields, SQL-to-RelNode conversion is slow because the operation to lookup a field within a record type is O(n) in the number of fields and is called O(n) times. This manifests in the method SqlToRelConverter.Blackboard.lookupExp. The solution we adopted is to add a map in RelRecordType from field names (case-sensitive) to fields (Julian Hyde). We hope that this map will improve performance in other parts of the planning process besides SQL-to-RelNode (e.g. validation and rewrite rules). If the record has 20 (RelRecordType.THRESHOLD) or fewer fields, the map is not populated. We believe that this saves memory and effort for the common case, small to medium-sized records. In SqlToRelConverter.Blackboard, change the contract of method lookupExp. It would previously return null if a field was not found, whereupon the caller would throw; now the method throws, and is declared not-nullable. The method previously returned a Map from field names to field ordinals, and now returns a Function that can convert a field name to an expression accessing that field; the new contract is easier to implement efficiently with available knowledge. Add a benchmark, RelNodeConversionBenchmark, that demonstrates improvement for tables with 100 and 1,000 fields (Jay Narale). Close apache#2701 Co-authored-by: Julian Hyde <jhyde@apache.org>
- Loading branch information
Showing
6 changed files
with
307 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.