cockroachdb / cockroachdb/cockroach

opt: do not blanket-exempt partial indexes from disallow_full_table_scans

Open
#123,754 0 comments 0 reactions 0 assignees View on GitHub
A-sql-optimizer C-enhancement O-support P-3 T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

In https://github.com/cockroachdb/cockroach/pull/71317 we added an exemption to `disallow_full_table_scans` for partial indexes, since by definition a full scan of a partial index is not a full scan of the table. But depending on the selectivity of the partial index predicate, a full scan of a partial index can still be very expensive.

Instead of a blanket exemption for partial indexes, we should only exempt them if the estimated row count of the full scan would be bellow `large_full_scan_rows`, as we do for full scans of full indexes.

Doing this accurately probably depends on https://github.com/cockroachdb/cockroach/issues/85176.

Jira issue: CRDB-38527

Contributor guide

Open the contributing guide

Research direction

Read PR 71317 to understand the existing partial-index exemption, then inspect the implementation of disallow_full_table_scans and issue 85176 for row-count estimation. Done means partial indexes are exempted only when the estimated full-scan row count is below large_full_scan_rows, with coverage for the relevant behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases, performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.