Skip to content

Conversation

arthurschreiber
Copy link
Contributor

@arthurschreiber arthurschreiber commented Aug 26, 2025

Description

This pull request intends to improve the performance of some of the queries executed by VDiff against the internal sidecar database.

These changes should be backported as the symptoms of the bad query performance can lead to grave issues (like crashing primary vttablets) when running VDiff.

Related Issue(s)

#18578

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

Signed-off-by: Arthur Schreiber <[email protected]>
Copy link
Contributor

vitess-bot bot commented Aug 26, 2025

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Aug 26, 2025
@github-actions github-actions bot added this to the v23.0.0 milestone Aug 26, 2025
@arthurschreiber arthurschreiber added Component: VTTablet and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Aug 26, 2025
@arthurschreiber arthurschreiber added Backport to: release-20.0 Needs to be backport to release-20.0 Backport to: release-21.0 Needs to be backport to release-21.0 Backport to: release-22.0 Needs to be backport to release-22.0 Type: Bug Type: Performance labels Aug 26, 2025
@arthurschreiber
Copy link
Contributor Author

Here's an explain plan for the example query from #18578 with the new schema, showing that we're no longer doing any full table scans:

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1.05"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "vd",
          "access_type": "index",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "state",
          "used_key_parts": [
            "state"
          ],
          "key_length": "67",
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.25",
            "eval_cost": "0.10",
            "prefix_cost": "0.35",
            "data_read_per_join": "4K"
          },
          "used_columns": [
            "id"
          ]
        }
      },
      {
        "table": {
          "table_name": "vdt",
          "access_type": "ref",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "vdiff_id"
          ],
          "key_length": "8",
          "ref": [
            "_vt.vd.id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.25",
            "eval_cost": "0.10",
            "prefix_cost": "0.70",
            "data_read_per_join": "2K"
          },
          "used_columns": [
            "vdiff_id"
          ]
        }
      },
      {
        "table": {
          "table_name": "vdl",
          "access_type": "ref",
          "possible_keys": [
            "vdiff_id_idx"
          ],
          "key": "vdiff_id_idx",
          "used_key_parts": [
            "vdiff_id"
          ],
          "key_length": "8",
          "ref": [
            "_vt.vd.id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.25",
            "eval_cost": "0.10",
            "prefix_cost": "1.05",
            "data_read_per_join": "32"
          },
          "used_columns": [
            "vdiff_id"
          ]
        }
      }
    ]
  }
}

@arthurschreiber arthurschreiber marked this pull request as ready for review August 26, 2025 13:54
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.49%. Comparing base (1c5ca23) to head (718221a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #18579      +/-   ##
==========================================
- Coverage   67.52%   67.49%   -0.03%     
==========================================
  Files        1607     1607              
  Lines      263324   263324              
==========================================
- Hits       177803   177741      -62     
- Misses      85521    85583      +62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dbussink dbussink removed the Backport to: release-20.0 Needs to be backport to release-20.0 label Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport to: release-21.0 Needs to be backport to release-21.0 Backport to: release-22.0 Needs to be backport to release-22.0 Component: VTTablet Type: Bug Type: Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants