Postgresql rename index

indexpostgresql

I want to understand how safe is the rename command:

ALTER INDEX old_name RENAME TO old_name;

The index was created by command(for the foreign key column):

CREATE INDEX old_name ON table_t1 (user_id);

Does it mean simple update in the postgres system tables or do much more operations. I try to find it in the docs but unsuccess.

Best Answer

Quote from the manual

The RENAME form changes the name of the index (...) There is no effect on the stored data

(emphasis mine)

So yes, this is a simple update to the system catalog.

The statement sill needs an exclusive lock on the table if I'm not mistaken, but the lock will only be held for a very short period.