Skip to content

Ability to enable/disable indexes through GUC #2

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shayonj
Copy link
Owner

@shayonj shayonj commented Sep 24, 2024

The patch introduces a new GUC parameter disabled_indexes that allows users to specify a comma-separated list of indexes to be ignored during query planning. Key aspects:

  • Adds a new isdisabled attribute to the IndexOptInfo structure.
  • Modifies get_relation_info in plancat.c to skip disabled indexes entirely, thus reducing the number of places we need to check if an index is disabled or not.
  • Implements GUC hooks for parameter validation and assignment.
  • Resets the plan cache when the disabled_indexes list is modified through ResetPlanCache()

I chose to modify the logic within get_relation_info as compared to, say, reducing the cost to make the planner not consider an index during planning, mostly to keep the number of changes being introduced to a minimum and also the logic itself being self-contained and easier to under perhaps (?).

As mentioned before, this does not impact the building of the index. That still happens.

I have added regression tests for:

  • Basic single-column and multi-column indexes
  • Partial indexes
  • Expression indexes
  • Join indexes
  • GIN and GiST indexes
  • Covering indexes
  • Range indexes
  • Unique indexes and constraints

@shayonj shayonj force-pushed the s/guc-based-disable-index branch 24 times, most recently from b201bbf to 24daa35 Compare September 26, 2024 17:38
The patch introduces a new GUC parameter `disabled_indexes` that allows users to specify a comma-separated list of indexes to be ignored during query planning. Key aspects:

- Adds a new `isdisabled` attribute to the `IndexOptInfo` structure.
- Modifies `get_relation_info` in `plancat.c` to skip disabled indexes entirely, thus reducing the number of places we need to check if an index is disabled or not.
- Implements GUC hooks for parameter validation and assignment.
- Resets the plan cache when the `disabled_indexes` list is modified through `ResetPlanCache()`

I chose to modify the logic within `get_relation_info` as compared to, say, reducing the cost to make the planner not consider an index during planning, mostly to keep the number of changes being introduced to a minimum and also the logic itself being self-contained and easier to under perhaps (?).

As mentioned before, this does not impact the building of the index. That still happens.

I have added regression tests for:

- Basic single-column and multi-column indexes
- Partial indexes
- Expression indexes
- Join indexes
- GIN and GiST indexes
- Covering indexes
- Range indexes
- Unique indexes and constraints
@shayonj shayonj force-pushed the s/guc-based-disable-index branch from 24daa35 to 0821dec Compare September 27, 2024 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant