[ 
https://issues.apache.org/jira/browse/CALCITE-4994?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17484505#comment-17484505
 ] 

Jay Narale commented on CALCITE-4994:
-------------------------------------

[~julianhyde]  Indeed it does, thank you for the support, I merged your commits 
into my [PR|https://github.com/apache/calcite/pull/2701]   , could you please 
review it?

Final benchmark with map at RelRecordType

 
{noformat}
Benchmark                                                             
(columnLength)  (length)  Mode  Cnt          Score           Error   Units
RelConversionBenchmark.convertToRel                                             
  10     10000  avgt   10        293.291 ±        15.347   ms/op
RelConversionBenchmark.convertToRel                                             
 100     10000  avgt   10        517.237 ±        48.409   ms/op
RelConversionBenchmark.convertToRel:·gc.time                                    
 100     10000  avgt   10        140.000                      ms
RelConversionBenchmark.convertToRel                                             
1000     10000  avgt   10       2679.441 ±        62.936   ms/op
RelConversionBenchmark.parse                                                    
  10     10000  avgt   10        860.819 ±        30.717   ms/op
RelConversionBenchmark.parse                                                    
 100     10000  avgt   10       1567.356 ±        54.543   ms/op
RelConversionBenchmark.parse:·gc.time                                           
 100     10000  avgt   10        106.000                      ms
RelConversionBenchmark.parse                                                    
1000     10000  avgt   10       8869.804 ±       396.192   ms/op
RelConversionBenchmark.parse:·gc.time                                           
1000     10000  avgt   10        210.000      {noformat}
 

 

 

> 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)

Reply via email to