[
https://issues.apache.org/jira/browse/CALCITE-4994?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17484915#comment-17484915
]
Julian Hyde edited comment on CALCITE-4994 at 1/31/22, 8:13 PM:
----------------------------------------------------------------
Your PR should also add a couple of lines to ubenchmark/README.md.
While you're there, can you fix the formatting issues that show up on
https://github.com/apache/calcite/tree/master/ubenchmark. (GitHub markdown
doesn't use "noformat".)
I'll rebase and squash your commits, and add myself as a co-author of the
squashed commit since we both worked in this.
I think the JIRA subject and commit subject should be "SQL-to-RelNode
conversion is slow if table contains hundreds of fields". Then we can explain
in the commit message how the problem is O\(n) lookup of fields within a record
data type, and how the solution is a map from field name to field in larger
record types.
was (Author: julianhyde):
Your PR should also add a couple of lines to ubenchmark/README.md.
While you're there, can you fix the formatting issues that show up on
https://github.com/apache/calcite/tree/master/ubenchmark. (GitHub markdown
doesn't use "noformat".)
I'll rebase and squash your commits, and add myself as a co-author of the
squashed commit since we both worked in this.
I think the JIRA subject and commit subject should be "SQL-to-RelNode
conversion is slow if table contains hundreds of fields". Then we can explain
in the commit message how the problem is O(n) lookup of fields within a record
data type, and how the solution is a map from field name to field in larger
record types.
> SqlToRelConverter creates FieldMap for every Identifier Instead of Memoizing
> it
> -------------------------------------------------------------------------------
>
> Key: CALCITE-4994
> URL: https://issues.apache.org/jira/browse/CALCITE-4994
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Jay Narale
> Priority: Major
> Labels: pull-request-available
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> 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_*
>
> {code:java}
> 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);{code}
>
> So for a Sql Query
> {code:java}
> SELECT name, nation FROM customer{code}
> 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.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)