Skip to content

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #55842

What problem does this PR solve?

Issue Number: close #55818

Problem Summary:

What changed and how does it work?

Because the JSON column will be without stats by default, the row count will be 0. But when calculating selectivity, we cannot divide by zero. it will get NaN row count.

image

why is the result wrong?

image

It will return NaN from Selectivity and break all stats info by ds.TableStats.Scale(selectivity)

image image

Final, The problem will be created at the joinReorderGreedySolver.solve-> constructConnectedJoinTree

image

checkConnectionAndMakeJoin will create a right join plan. but when to calculate the cost, it will get NaN because of the pollute stats info. we cannot get best join because of Nan > math.MaxFloat64. makeBushyJoin will not consider the EqCondtion. Many condition will lose. This is the reason why it will get wrong result.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Due to incorrect statistics, the filter condition was completely removed.

before



+---------------------------+---------+-----------+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                        | estRows | task      | access object   | operator info                                                                                                                                                                            |
+---------------------------+---------+-----------+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_12             | NaN     | root      |                 | 1->Column#18                                                                                                                                                                             |
| └─HashJoin_13             | NaN     | root      |                 | CARTESIAN inner join                                                                                                                                                                     |
|   ├─TableReader_19(Build) | 38.00   | root      |                 | data:TableFullScan_18                                                                                                                                                                    |
|   │ └─TableFullScan_18    | 38.00   | cop[tikv] | table:t61a85298 | keep order:false, stats:pseudo                                                                                                                                                           |
|   └─TableReader_17(Probe) | NaN     | root      | partition:all   | data:Selection_16                                                                                                                                                                        |
|     └─Selection_16        | NaN     | cop[tikv] |                 | or(json_memberof(cast(16739493649928310215, json BINARY), test.tceb7972c.col_17), not(istrue_with_null(json_contains(test.tceb7972c.col_17, cast("6019730272580550835", json BINARY))))) |
|       └─TableFullScan_15  | 12.00   | cop[tikv] | table:tceb7972c | keep order:false, stats:partial[col_17:unInitialized]                                                                                                                                    |
+---------------------------+---------+-----------+-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

after

id  estRows task  access object operator info
Projection_11 6.00  root    1->Column#18
└─HashJoin_13 6.00  root    inner join, equal:[eq(test.tceb7972c.col_19, Column#19)]
  ├─TableReader_16(Build) 4.80  root  partition:all data:Selection_15
  │ └─Selection_15  4.80  cop[tikv]   or(json_memberof(cast(16739493649928310215, json BINARY), test.tceb7972c.col_17), not(istrue_with_null(json_contains(test.tceb7972c.col_17, cast("6019730272580550835", json BINARY)))))
  │   └─TableFullScan_14  6.00  cop[tikv] table:tceb7972c keep order:false, stats:partial[col_17:missing]
  └─Projection_17(Probe)  10000.00  root    cast(test.t61a85298.col_71, double BINARY)->Column#19
    └─TableReader_19  10000.00  root    data:TableFullScan_18
      └─TableFullScan_18  10000.00  cop[tikv] table:t61a85298 keep order:false, stats:pseudo
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR. labels Sep 6, 2024
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 6, 2024
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Please upload report for BASE (release-8.1@d00c55f). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.1     #55924   +/-   ##
================================================
  Coverage               ?   71.2154%           
================================================
  Files                  ?       1466           
  Lines                  ?     423067           
  Branches               ?          0           
================================================
  Hits                   ?     301289           
  Misses                 ?     101303           
  Partials               ?      20475           
Flag Coverage Δ
unit 71.2154% <0.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9656% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 41.3451% <0.0000%> (?)

Signed-off-by: Weizhen Wang <[email protected]>
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Sep 9, 2024
@ti-chi-bot ti-chi-bot bot added the lgtm label Sep 9, 2024
Copy link

ti-chi-bot bot commented Sep 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, time-and-fate

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [hawkingrei,time-and-fate]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 9, 2024
Copy link

ti-chi-bot bot commented Sep 9, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-06 14:13:37.382124792 +0000 UTC m=+20087.122548724: ☑️ agreed by hawkingrei.
  • 2024-09-09 09:07:43.335838486 +0000 UTC m=+260933.076262461: ☑️ agreed by time-and-fate.

@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit a6789fd into pingcap:release-8.1 Sep 9, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-8.1 This PR is cherry-picked to release-8.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants