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

Konstantin Orlov commented on IGNITE-16919:
-------------------------------------------

I've taken another look, and now I see, it's definitely a bug. It's hard to 
comprehend without any test or reproducer...

For the history: without the fix, we sometimes double the cost of an index just 
because we mistakenly suppose there are columns which aren't covered by the 
current index, so the read from the scan index is required.

BTW, as far as I know, we always read the data row from the page, and do it 
only once despite all columns are covered by the index or not. Perhaps, we 
should revisit this place.

> H2 Index cost function must take into account only corresponding columns.
> -------------------------------------------------------------------------
>
>                 Key: IGNITE-16919
>                 URL: https://issues.apache.org/jira/browse/IGNITE-16919
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>    Affects Versions: 2.13
>            Reporter: Evgeny Stanilovsky
>            Assignee: Evgeny Stanilovsky
>            Priority: Major
>         Attachments: image-2022-04-30-19-13-59-997.png
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> H2IndexCostedBase#getCostRangeIndex is called with allColumnsSet where 
> consists columns from all operating tables, check: 
> org.h2.table.Plan#calculateCost :
> {code:java}
>         final HashSet<Column> allColumnsSet = ExpressionVisitor
>                 .allColumnsForTableFilters(allFilters);
> {code}
> thus allColumnsSet consist columns from all operating tables
>  !image-2022-04-30-19-13-59-997.png! 
> and erroneous iteration here:
> H2IndexCostedBase#getCostRangeIndex
> ...
> {code:java}
> if (!isScanIndex && allColumnsSet != null && !skipColumnsIntersection && 
> !allColumnsSet.isEmpty()) {
>             boolean foundAllColumnsWeNeed = true;
>             for (Column c : allColumnsSet) { // <-- all columns
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to