From: | Shayon Mukherjee <shayonj(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Benoit Lobréau <benoit(dot)lobreau(at)gmail(dot)com>, Sami Imseih <samimseih(at)gmail(dot)com>, Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch) |
Date: | 2025-02-23 15:41:11 |
Message-ID: | CANqtF-oUMCVYbCO9tJNmMUOPCwJQ=1LamrHyau8qen1nOckxgw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sat, Feb 8, 2025 at 12:41 AM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
> hi.
> ```
> drop table if exists idxpart;
> create table idxpart (a int, b int, c text) partition by range (a);
> create table idxpart1 (like idxpart);
> alter table idxpart attach partition idxpart1 for values from (0) to (10);
>
> create index idxpart_c on only idxpart (c) invisible;
> create index idxpart1_c on idxpart1 (c);
>
> alter index idxpart_c attach partition idxpart1_c;
> ```
> In this case, should ALTER INDEX ATTACH PARTITION change the attached
> partition(idxpart1_c)'s "visible" status?
>
>
Hi,
That is a great question and I have really gone back and forth on this one
and here's my reasoning so far
1. When you don't use ONLY:
- The index of child table inherits the visibility of the parent table's
index
- This applies whether the parent index is set as INVISIBLE or VISIBLE
- This automatic inheritance is expected behavior and feels natural
2. When you use ONLY:
- You as a user/developer are explicitly taking control of index
management
- Creating an index for parent as INVISIBLE and another for child as
VISIBLE represents conscious, deliberate choices
- When attaching these indexes, it makes sense to respect these explicit
visibility settings
- Silently overriding the child index's visibility could violate the
Principle of Least Surprise
- Lastly, this model also allows more granular control over index
visibility for each partition
I am not strongly tied to either of these options and very much open to
changing my mind. Also happy to try and document this for more clarity.
I have rebased the patch on top of master (resolving some merge conflicts),
along with the meson changes (thank you for that).
Thanks,
Shayon
Attachment | Content-Type | Size |
---|---|---|
v12-0001-Introduce-the-ability-to-set-index-visibility-us.patch | application/octet-stream | 84.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-02-23 16:49:21 | Re: [PoC] Federated Authn/z with OAUTHBEARER |
Previous Message | Jelte Fennema-Nio | 2025-02-23 15:05:34 | Re: Adding extension default version to \dx |