why does reindex invalidate relcache without modifying system tables

From: wenjing zeng <wjzeng2012(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: why does reindex invalidate relcache without modifying system tables
Date: 2021-12-27 09:09:31
Message-ID: 5F38F5EA-2565-419F-A93C-7E31AFB1628E@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tom

I would like to ask you about the details of index build.
I found that in the index_update_stats function, i.e. the CREATE INDEX/REINDEX/Truncate INDEX process,
relchche is invalidated whether the index information is updated. I want to know why you're did this
The code is:
if (dirty)
{
heap_inplace_update(pg_class, tuple);
/* the above sends a cache inval message */ }
else
{
/* no need to change tuple, but force relcache inval anyway */
CacheInvalidateRelcacheByTuple(tuple);
}

There's a special line of comment here, and I think you wrote that part for some reason.

The reason I ask this question is that
1 similar places like the vac_update_relstats /vac_update_datfrozenxid function don't do this.
2 Local Temp table with ON COMMIT DELETE ROWS builds index for each transaction commit.
This causes relcache of the temp table to be rebuilt over and over again.

Looking forward to your reply.

Thanks

Wenjing

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sascha Kuhl 2021-12-27 10:08:42 Re: Add Boolean node
Previous Message Pavel Stehule 2021-12-27 09:08:19 Re: Add Boolean node