Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-04-01 Thread Shayon Mukherjee
On Tue, Apr 1, 2025 at 2:41 PM Sami Imseih wrote: > I went back to look at this patch and a few things. I noticed it did > not have correct > indentation, so I ran pgindent. I also removed some extra lines added and > made > some slight adjustments to the docs. Attached my edited patch as a txt.

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-04-01 Thread Sami Imseih
I went back to look at this patch and a few things. I noticed it did not have correct indentation, so I ran pgindent. I also removed some extra lines added and made some slight adjustments to the docs. Attached my edited patch as a txt. If you agree, please revise into a v14. I also noticed that b

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-03-16 Thread Shayon Mukherjee
Hi Hackers, Just leaving a quick note: I know this patch has through a lot of variations. I am keen on shipping this for v18 if possible, and while it’s a learning process for me, I am more than happy to iterate on any feedback. Let me know if there is anything I can do to help to keep the mome

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-03-07 Thread Shayon Mukherjee
On Sun, Feb 23, 2025 at 3:41 PM Shayon Mukherjee wrote: > I have rebased the patch on top of master (resolving some merge > conflicts), along with the meson changes (thank you for that). > Rebased against the latest master and attaching the v13 patch. Thank you Shayon v13-0001-Introduce-the-a

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-02-23 Thread Shayon Mukherjee
On Sat, Feb 8, 2025 at 12:41 AM jian he 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 id

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-02-07 Thread jian he
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 o

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-02-04 Thread Shayon Mukherjee
On Sun, Feb 2, 2025 at 3:11 PM jian he wrote: > hi. > the following reviews based on > v10-0001-Introduce-the-ability-to-set-index-visibility-us.patch. > > Thank you for the amazing review!! > in src/test/regress/sql/create_index.sql > seems there are no sql tests for "create index ... invisibl

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-02-02 Thread jian he
hi. modules/test_ddl_deparse/test_ddl_deparse.so.p/test_ddl_deparse.c.o -c ../../Desktop/pg_src/src7/postgres/src/test/modules/test_ddl_deparse/test_ddl_deparse.c ../../Desktop/pg_src/src7/postgres/src/test/modules/test_ddl_deparse/test_ddl_deparse.c: In function ‘get_altertable_subcmdinfo’: .

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-02-02 Thread jian he
hi. the following reviews based on v10-0001-Introduce-the-ability-to-set-index-visibility-us.patch. in src/test/regress/sql/create_index.sql seems there are no sql tests for "create index ... invisible"? VISIBLE Make the specified index visible. The index will be used fo

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-31 Thread Shayon Mukherjee
On Fri, Jan 24, 2025 at 8:56 PM Benoit Lobréau wrote: > I also noticed that \d on an index doesn't warn about the invisible state > whereas \d on a table does: > Thank you for the review + patch (v9-002) [1]. Your patch looks good to me. I have not incorporated this in my v10 patch [2]. Mostly t

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-31 Thread Shayon Mukherjee
On Fri, Jan 24, 2025 at 4:03 PM Benoit Lobréau wrote: > I did notice something in the command prototype: > > +ALTER INDEX [ IF EXISTS ] class="parameter">name VISIBLE > +ALTER INDEX [ IF EXISTS ] class="parameter">name INVISIBLE > > it would probably be better as: > > +ALTER INDEX [ IF EXISTS

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-31 Thread Shayon Mukherjee
On Fri, Jan 31, 2025 at 10:18 AM Sami Imseih wrote: > > What is being discussed here is different from what I can tell. This > is referring > to the index changing status ( visible/invisible ) and those changes being > visible by another transaction. > > +1. My vote would be to keep the behavior

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-30 Thread Sami Imseih
> I had the "BEGIN; ALTER INDEX; EXPLAIN; ROLLBACK;" scenario in mind, but > didn't realise we acquire an AccessExclusiveLock on the index. Therefore, it's > not possible to change the visibility within a single transaction > unless you don’t mind blocking all access to the relation. > > I read

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-30 Thread Benoit Lobréau
I did some additional testing with this command within transactions. I had the "BEGIN; ALTER INDEX; EXPLAIN; ROLLBACK;" scenario in mind, but didn't realise we acquire an AccessExclusiveLock on the index. Therefore, it's not possible to change the visibility within a single transaction unless

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-24 Thread Benoit Lobréau
I also noticed that \d on an index doesn't warn about the invisible state whereas \d on a table does: [local]:5444 postgres@postgres=# SELECT indexrelid::regclass, indisvalid, indisvisible FROM pg_index WHERE indexrelid = 'repli_pkey'::regclass \gx -[ RECORD 1 ]+--- indexrelid | repli_pk

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-24 Thread Benoit Lobréau
On Fri, Jan 24, 2025 at 11:32 AM Benoit Lobréau wrote: > The completion for the INVISIBLE / VISIBLE keyword is missing in psql. I think this should to the trick ? diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 81cbf10aa28..43ea8e55fd0 100644 --- a/src/bin/psql

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-24 Thread Benoit Lobréau
Hi, Thank you for the patch! I've had a need for this feature several times, so I appreciate the work you’ve put into it. I like the new name VISIBLE/INVISIBLE and the fact that it's a separate flag in pg_index (it's easy to monitor). I don’t feel qualified to provide an opinion on the code itse

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-12 Thread Shayon Mukherjee
On Sat, Jan 11, 2025 at 5:50 PM Sami Imseih wrote: > Here is a use-case where the GUC may be useful. I can see a user > wanting to try out the index before committing to using it across the > board. They can create the index as invisible and force using > it in a specific part of the application.

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-11 Thread Sami Imseih
Thanks for the updates patch! >> This got me thinking if dropping the index is the only >> use case we really care about. For example, you may want >> to prevent an index that is enforcing a constraint from >> being used by the planner, but you probably don't want to >> drop it. In fact, I also th

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-11 Thread Shayon Mukherjee
On Fri, Jan 3, 2025 at 4:09 PM Sami Imseih wrote: > + This is the > + default state for newly created indexes. > > This is not needed in the ALTER INDEX docs, IMO.ss > > Updated and attached the patch. > This got me thinking if dropping the index is the only > use case we really care

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-03 Thread Sami Imseih
+ This is the + default state for newly created indexes. This is not needed in the ALTER INDEX docs, IMO.ss + + Disable the specified index. A disabled index is not used for queries, but it + is still updated when the underlying table data changes and will still be +

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2025-01-01 Thread Michail Nikolaev
Hello! > Given this is working as expected, would we still need a migration step? No, it is clear now. Thanks for explaining. Best regards, Mikhail.

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-31 Thread Shayon Mukherjee
On Mon, Dec 30, 2024 at 3:48 PM Michail Nikolaev wrote: > Hello! > > One more thing (maybe I missed it in the patch, but anyway) - should we > add some migration to ensure what old databases will get enabled=true by > default after upgrade? > Hi! Thank you! I tested this by manually upgrading (

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-31 Thread Shayon Mukherjee
On Mon, Dec 30, 2024 at 2:56 PM Sami Imseih wrote: > > Rebased with the latest master as well. > > Hi, > > This is a great, long needed feature. Thanks for doing this. > > I am late to this thread, but I took a look at the current patch > and have some comments as I continue to look. > > Thank yo

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-30 Thread Sami Imseih
> Should this not behave like if you drop (or create) an index > during a prepared statement? I have not yet looked closely at > this code to see what could be done. > > Regards, I looked at this a bit more and ATExecEnableDisableIndex needs some tweaks. What should be getting invalidated in the

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-30 Thread Michail Nikolaev
Hello! One more thing (maybe I missed it in the patch, but anyway) - should we add some migration to ensure what old databases will get enabled=true by default after upgrade? Best regards, Mikhail.

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-30 Thread Sami Imseih
> Rebased with the latest master as well. Hi, This is a great, long needed feature. Thanks for doing this. I am late to this thread, but I took a look at the current patch and have some comments as I continue to look. 1/ instead of + If true, the index is currently enabled and should be

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-30 Thread Shayon Mukherjee
On Mon, Dec 30, 2024 at 11:08 AM Michail Nikolaev < michail.nikol...@gmail.com> wrote: > Hello. > > A few comments on patch: > Thank you for the feedback. > > > + temporarily reducing the overhead of index maintenance > > + during bulk data loading operations > >> > But tuples are still ins

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-30 Thread Michail Nikolaev
Hello. A few comments on patch: > + temporarily reducing the overhead of index maintenance > + during bulk data loading operations > But tuples are still inserted, where the difference come from? > or verifying an index is not being used > + before dropping it Hm, it does not provide

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-28 Thread Shayon Mukherjee
On Fri, Dec 6, 2024 at 11:24 AM Shayon Mukherjee wrote: > The patch is also rebased against the latest master and passing in CI. > Would love to receive any further feedback on it. > > Rebased the last patch against the latest master from today as a v5. No other changes since last post. Shayon

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-12-06 Thread Shayon Mukherjee
On Mon, Nov 25, 2024 at 6:19 PM David Rowley wrote: > Another safer option could be to disallow the enable/disable ALTER > TABLE if indcheckxmin is true. We do have and use > ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE for these sorts of issues. > There are other existing failure modes relating to i

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-11-25 Thread David Rowley
On Tue, 26 Nov 2024 at 11:34, Shayon Mukherjee wrote: > Thank you for the guidance and tips. I was wondering if updating in-place is > preferable or not, since my first instinct was to avoid it. I did not notice > any breakage last time, unless I was looking in the wrong place (possibly?). > I

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-11-25 Thread Shayon Mukherjee
> On Nov 5, 2024, at 10:55 AM, Robert Haas wrote: > > On Thu, Oct 17, 2024 at 9:59 AM Shayon Mukherjee wrote: >> My take away from whether or not an in-place update is needed on pg_index [1] >> >> - It’s unclear to me why it’s needed. >> - I understand the xmin would get incremented when using

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-11-05 Thread Robert Haas
On Thu, Oct 17, 2024 at 9:59 AM Shayon Mukherjee wrote: > My take away from whether or not an in-place update is needed on pg_index [1] > > - It’s unclear to me why it’s needed. > - I understand the xmin would get incremented when using CatalogTupleUpdate > to update indisenabled. > - However, I

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-11-05 Thread Rafia Sabih
Interesting idea. This patch needs a rebase. On Thu, 17 Oct 2024 at 15:59, Shayon Mukherjee wrote: > > > On Oct 16, 2024, at 6:01 PM, Shayon Mukherjee wrote: > > I'll take some time to think this through and familiarize myself with the > new systable_inplace_update_begin. In the meantime, aside

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-10-17 Thread Shayon Mukherjee
On Oct 16, 2024, at 6:01 PM, Shayon Mukherjee wrote: I'll take some time to think this through and familiarize myself with the new systable_inplace_update_begin. In the meantime, aside from the in-place updates on pg_index, I would love to learn any first impressions or feedback on the patch folk

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-10-16 Thread Shayon Mukherjee
> On Oct 16, 2024, at 2:15 PM, Shayon Mukherjee wrote: > > >> On Oct 16, 2024, at 12:19 PM, Shayon Mukherjee wrote: >> >> - ALTER INDEX ... ENABLE/DISABLE performs an in-place update of the pg_index >> catalog to protect against indcheckxmin [2] (older unrelated thread). > > Performing th

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-10-16 Thread Shayon Mukherjee
On Oct 16, 2024, at 12:19 PM, Shayon Mukherjee wrote:- ALTER INDEX ... ENABLE/DISABLE performs an in-place update of the pg_index   catalog to protect against indcheckxmin [2] (older unrelated thread).Performing the in place update of the pg_index row from ATExecEnableDisableIndex using systable_i

Re: Proposal to Enable/Disable Index using ALTER INDEX (with patch)

2024-10-16 Thread Shayon Mukherjee
On Oct 15, 2024, at 7:25 PM, David Rowley wrote:On Wed, 16 Oct 2024 at 03:40, Robert Haas wrote:On Sat, Oct 12, 2024 at 5:56 AM Shayon Mukherjee wrote:Thank you for sharing this Robert. I like the idea behind "allowing extensions to control planner behavior” overall and I think it does help towa