You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xiaochen-zhou (via GitHub)" <gi...@apache.org> on 2025/01/05 01:23:20 UTC

[PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

xiaochen-zhou opened a new pull request, #4125:
URL: https://github.com/apache/calcite/pull/4125

   Our current logic using a PriorityQueue to select the tile with the fewest rows when multiple tiles are available. However, there are several potential issues:
   
   1. The PriorityQueue stores all satisfiable tiles. When the number of tiles is large, maintaining the heap structure during element insertion has a time complexity of O(log n), which also increases memory usage.
   2. The initial size of the PriorityQueue is difficult to estimate and is currently set to 1, causing frequent resizing of the PriorityQueue.
   
   We can optimize the code by keeping only a single bestCandidate tile to improve performance.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #4125:
URL: https://github.com/apache/calcite/pull/4125


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2598905222

   > What is the conclusion from the JIRA discussion? Can we merge this?
   
   I recently attempted to add a benchmark by referring to CALCITE-4994 and CALCITE-3827.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2577298938

   > There are some comments in Jira from @julianhyde, so I will wait to merge this.
   
   OK.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2997166032

   I will merge this PR even without an obvious perf improvement, since it makes the code simpler.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2576458875

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4125) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4125&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4125&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4125&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4125&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4125&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4125)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "ILuffZhe (via GitHub)" <gi...@apache.org>.
ILuffZhe commented on code in PR #4125:
URL: https://github.com/apache/calcite/pull/4125#discussion_r1904782014


##########
core/src/main/java/org/apache/calcite/materialize/MaterializationService.java:
##########
@@ -241,8 +240,7 @@ private MaterializationService() {
     // TODO: Use a partially-ordered set data structure, so we are not scanning
     // through all tiles.
     if (!exact) {
-      final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<>(1, C);
+      Pair<CalciteSchema.TableEntry, TileKey> bestCandidate = null;

Review Comment:
   > can the TODO comment above be deleted?
   
   +1 with Mihai.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on code in PR #4125:
URL: https://github.com/apache/calcite/pull/4125#discussion_r1904809664


##########
core/src/main/java/org/apache/calcite/materialize/MaterializationService.java:
##########
@@ -241,8 +240,7 @@ private MaterializationService() {
     // TODO: Use a partially-ordered set data structure, so we are not scanning
     // through all tiles.
     if (!exact) {
-      final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<>(1, C);
+      Pair<CalciteSchema.TableEntry, TileKey> bestCandidate = null;

Review Comment:
   > > can the TODO comment above be deleted?
   > 
   > I don't think it can be deleted yet. The keyByTile data structure needs to be changed from a Map to a partially-ordered set data structure to avoid scanning through all tiles. Only then can it be removed. @ILuffZhe 
    ![image](https://private-user-images.githubusercontent.com/27844885/400605215-4eac0cde-338d-48db-a5c0-7a5f2ced446d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYyMTQ1OTAsIm5iZiI6MTczNjIxNDI5MCwicGF0aCI6Ii8yNzg0NDg4NS80MDA2MDUyMTUtNGVhYzBjZGUtMzM4ZC00OGRiLWE1YzAtN2E1ZjJjZWQ0NDZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA3VDAxNDQ1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk5OTA5YjRiYjA0OTYxNDg3MWIwMjRlYzUyOGQ0ZjA2NGZjMGZhNjM4YzczZTY4Mzc4MWI5NDE0NmJlYjY2ODcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.DVFtQtG7o-cLX_waOCO_ZDK5S862LMUomAz5MDuxBPg)
   
   



##########
core/src/main/java/org/apache/calcite/materialize/MaterializationService.java:
##########
@@ -241,8 +240,7 @@ private MaterializationService() {
     // TODO: Use a partially-ordered set data structure, so we are not scanning
     // through all tiles.
     if (!exact) {
-      final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<>(1, C);
+      Pair<CalciteSchema.TableEntry, TileKey> bestCandidate = null;

Review Comment:
   > > can the TODO comment above be deleted?
   > 
   > I don't think it can be deleted yet. The keyByTile data structure needs to be changed from a Map to a partially-ordered set data structure to avoid scanning through all tiles. Only then can it be removed. @ILuffZhe 
    ![image](https://private-user-images.githubusercontent.com/27844885/400605215-4eac0cde-338d-48db-a5c0-7a5f2ced446d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYyMTQ1OTAsIm5iZiI6MTczNjIxNDI5MCwicGF0aCI6Ii8yNzg0NDg4NS80MDA2MDUyMTUtNGVhYzBjZGUtMzM4ZC00OGRiLWE1YzAtN2E1ZjJjZWQ0NDZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA3VDAxNDQ1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk5OTA5YjRiYjA0OTYxNDg3MWIwMjRlYzUyOGQ0ZjA2NGZjMGZhNjM4YzczZTY4Mzc4MWI5NDE0NmJlYjY2ODcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.DVFtQtG7o-cLX_waOCO_ZDK5S862LMUomAz5MDuxBPg)
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2599061199

   So should we wait for benchmark results?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4125:
URL: https://github.com/apache/calcite/pull/4125#discussion_r1904722375


##########
core/src/main/java/org/apache/calcite/materialize/MaterializationService.java:
##########
@@ -241,8 +240,7 @@ private MaterializationService() {
     // TODO: Use a partially-ordered set data structure, so we are not scanning
     // through all tiles.
     if (!exact) {
-      final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<>(1, C);
+      Pair<CalciteSchema.TableEntry, TileKey> bestCandidate = null;

Review Comment:
   can the TODO comment above be deleted?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2576605406

   There are some comments in Jira from @julianhyde, so I will wait to merge this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #4125:
URL: https://github.com/apache/calcite/pull/4125#discussion_r1925220167


##########
core/src/main/java/org/apache/calcite/materialize/MaterializationService.java:
##########
@@ -254,13 +252,13 @@ && allSatisfiable(measureList, tileKey2)) {
           final CalciteSchema.TableEntry tableEntry =
               checkValid(materializationKey);
           if (tableEntry != null) {
-            queue.add(Pair.of(tableEntry, tileKey2));
+            Pair<CalciteSchema.TableEntry, TileKey> candidate = Pair.of(tableEntry, tileKey2);
+            if (bestCandidate == null || C.compare(candidate, bestCandidate) < 0) {
+              bestCandidate = candidate;
+            }
           }
         }
       }
-      if (!queue.isEmpty()) {

Review Comment:
   Shouldn't we have a
   ```
   if (bestCandidate != null)
     return bestCandidate;
   ```
   at this place in the patch to maintain the previous logic?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2571467975

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4125) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4125&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4125&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4125&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4125&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4125&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4125)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "ILuffZhe (via GitHub)" <gi...@apache.org>.
ILuffZhe commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2574184794

   > There are no tests - is there any code calling this function? If yes, then it's perhaps fine - the behavior is not supposed to change.
   
   +1.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2576441643

   > you can probably squash the commits
   
   Done.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2995199049

   > Will you continue to complete this PR?
   
   Sorry, I couldn't find a suitable method to test the performance. @mihaibudiu 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2574230779

   
   
   
   
   > There are no tests - is there any code calling this function? If yes, then it's perhaps fine - the behavior is not supposed to change.
   
   RelOptLattice#getAggregate() call this method.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2596393487

   What is the conclusion from the JIRA discussion? Can we merge this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2927249904

   Will you continue to complete this PR?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2599443621

   > So should we wait for benchmark results?
   
   Yes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on code in PR #4125:
URL: https://github.com/apache/calcite/pull/4125#discussion_r1904809069


##########
core/src/main/java/org/apache/calcite/materialize/MaterializationService.java:
##########
@@ -241,8 +240,7 @@ private MaterializationService() {
     // TODO: Use a partially-ordered set data structure, so we are not scanning
     // through all tiles.
     if (!exact) {
-      final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<>(1, C);
+      Pair<CalciteSchema.TableEntry, TileKey> bestCandidate = null;

Review Comment:
   > can the TODO comment above be deleted?
   
   I don't think it can be deleted yet. The keyByTile data structure needs to be changed from a Map to a partially-ordered set data structure to avoid scanning through all tiles. Only then can it be removed.
   ![image](https://github.com/user-attachments/assets/4eac0cde-338d-48db-a5c0-7a5f2ced446d)
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "xiaochen-zhou (via GitHub)" <gi...@apache.org>.
xiaochen-zhou commented on code in PR #4125:
URL: https://github.com/apache/calcite/pull/4125#discussion_r1904809069


##########
core/src/main/java/org/apache/calcite/materialize/MaterializationService.java:
##########
@@ -241,8 +240,7 @@ private MaterializationService() {
     // TODO: Use a partially-ordered set data structure, so we are not scanning
     // through all tiles.
     if (!exact) {
-      final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<>(1, C);
+      Pair<CalciteSchema.TableEntry, TileKey> bestCandidate = null;

Review Comment:
   > can the TODO comment above be deleted?
   
   I don't think it can be deleted yet. The keyByTile data structure needs to be changed from a Map to a partially-ordered set data structure to avoid scanning through all tiles. Only then can it be removed. @mihaibudiu @ILuffZhe 
   ![image](https://github.com/user-attachments/assets/4eac0cde-338d-48db-a5c0-7a5f2ced446d)
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6763] Optimize logic to select the tiles with the fewest rows [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4125:
URL: https://github.com/apache/calcite/pull/4125#issuecomment-2574402392

   you can probably squash the commits


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org