Skip to content

Add support for 'ONLY' predicate in Index creation dialog. #6386#9643

Open
RohitBhati8269 wants to merge 1 commit intopgadmin-org:masterfrom
RohitBhati8269:GH-6386
Open

Add support for 'ONLY' predicate in Index creation dialog. #6386#9643
RohitBhati8269 wants to merge 1 commit intopgadmin-org:masterfrom
RohitBhati8269:GH-6386

Conversation

@RohitBhati8269
Copy link
Contributor

@RohitBhati8269 RohitBhati8269 commented Feb 18, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Added "Only Table?" toggle to the index creation form. This switch allows users to optionally apply the ONLY modifier when creating indexes on partitioned tables, restricting the index to the specified table only. The toggle is only available during index creation.

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Walkthrough

Introduces a new "Only Table?" toggle in the PostgreSQL index creation UI that allows users to create indexes on only the specified table, with corresponding SQL template updates to conditionally include the ONLY modifier in CREATE INDEX statements across PostgreSQL versions 11, 13, and 15+.

Changes

Cohort / File(s) Summary
UI Schema Definition
web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js
Added new indisonly boolean field to IndexSchema with default value false. Includes a switch control labeled "Only Table?" that appears in the Definition group during create mode and is disabled when not on a partitioned table or in schema mode.
SQL Template Updates
web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/indexes/sql/11_plus/create.sql, 13_plus/create.sql, 15_plus/create.sql
Updated CREATE INDEX ON clause across all version-specific templates to conditionally prepend ONLY modifier when data.indisonly is true, changing syntax from "ON schema.table" to "ON ONLY schema.table".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • anilsahoo20
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for the ONLY predicate in the Index creation dialog, matching the PR's actual modifications across UI and SQL templates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/static/js/index.ui.js`:
- Around line 528-535: The indisonly control currently allows being set together
with isconcurrent which produces invalid SQL; update the indisonly field
definition (the disabled callback for indexSchemaObj.node_info) to include deps:
['isconcurrent'] and return true when state.isconcurrent is truthy (preventing
ONLY when CONCURRENTLY is selected), and additionally add a mutual-exclusion
check in the form validate() (or in the index creation validator) to reject the
combination of state.isconcurrent and state.indisonly with a clear validation
error; reference the indisonly field's disabled callback, deps:
['isconcurrent'], state.isconcurrent, and the validate() function to implement
both the UI disable and the validation guard.
- Around line 526-536: The 'indisonly' field in the index field definition is
missing a PostgreSQL version guard; update the field object (id: 'indisonly'
within the index UI schema) to include min_version: 110000 so the switch is only
shown/active for PG >= 11 connections (consistent with other guarded fields like
'deduplicate_items' and 'indnullsnotdistinct'), leaving the existing disabled
and helpMessage logic intact and using indexSchemaObj.node_info for context as
before.
- Line 535: Update the helpMessage for the ONLY option in index.ui.js (the
helpMessage property) to explicitly state that using ONLY creates the index only
on that table and the resulting index is initially marked INVALID; also mention
that the index becomes valid once matching indexes exist on partitions (e.g.,
via ALTER INDEX ... ATTACH PARTITION). Modify the gettext string accordingly so
users know the index won't be usable immediately and how it can be made valid.

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