Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt: wrong index alteration recommendation when multiple invisible indexes exist #108490

Closed
rytaft opened this issue Aug 9, 2023 · 0 comments · Fixed by #108576
Closed

opt: wrong index alteration recommendation when multiple invisible indexes exist #108490

rytaft opened this issue Aug 9, 2023 · 0 comments · Fixed by #108576
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@rytaft
Copy link
Collaborator

rytaft commented Aug 9, 2023

Describe the problem

When there are multiple invisible indexes in a table, ALTER INDEX ... VISIBLE index recommendations may suggest making the wrong index visible.

To Reproduce

On master or 23.1, run cockroach demo, and then run the following:

CREATE TABLE t_notvisible (
  k INT PRIMARY KEY,
  v INT,
  i INT,
  j INT,
  INDEX idx_i_visible(i) VISIBLE,
  INDEX idx_v_invisible(v) NOT VISIBLE,
  INDEX idx_j_invisible(j) NOT VISIBLE
);

EXPLAIN SELECT j FROM t_notvisible WHERE j > 1;

This produces:

                                      info
---------------------------------------------------------------------------------
  distribution: local
  vectorized: true

  • filter
  │ filter: j > 1
  │
  └── • scan
        missing stats
        table: t_notvisible@t_notvisible_pkey
        spans: FULL SCAN

  index recommendations: 1
  1. type: index alteration
     SQL command: ALTER INDEX movr.public.t_notvisible@idx_v_invisible VISIBLE;
(14 rows)

Notice that the index recommendation is to make idx_v_invisible, which is not useful for the given query.

Expected behavior

We should recommend to make idx_j_invisible visible instead.

Jira issue: CRDB-30491

@rytaft rytaft added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Aug 9, 2023
@rytaft rytaft self-assigned this Aug 9, 2023
craig bot pushed a commit that referenced this issue Aug 11, 2023
108472: roachtest: delete archaic jobs/mixed-version test r=dt a=adityamaru

This roachtest has dubious intentions. The expected logic on job cancellation and failure is specific to the job type. It is more useful to write job type specific unit tests rather than a roachtest to test these behaviours.

Fixes: #67587
Release note: None

108576: opt: fix index alteration recommendation for multiple invisible indexes r=rytaft a=rytaft

Fixes #108490

Release note (bug fix): Fixed a bug in the index recommendations provided in the `EXPLAIN` output where `ALTER INDEX ... VISIBLE` index recommendations may suggest making the wrong index visible when there are multiple invisible indexes in a table.

Co-authored-by: adityamaru <adityamaru@gmail.com>
Co-authored-by: Rebecca Taft <becca@cockroachlabs.com>
@craig craig bot closed this as completed in 507e594 Aug 11, 2023
rytaft added a commit that referenced this issue Aug 12, 2023
Fixes #108490

Release note (bug fix): Fixed a bug in the index recommendations provided in
the EXPLAIN output where ALTER INDEX ... VISIBLE index recommendations may
suggest making the wrong index visible when there are multiple invisible
indexes in a table.
rytaft added a commit that referenced this issue Aug 12, 2023
Fixes #108490

Release note (bug fix): Fixed a bug in the index recommendations provided in
the EXPLAIN output where ALTER INDEX ... VISIBLE index recommendations may
suggest making the wrong index visible when there are multiple invisible
indexes in a table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant