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.

  • @McNets thank you for help with the question details, no it is index without any features. – Bear Brown Dec 3 '18 at 11:50
  • @McNets: that link is irrelevant for Postgres as it is about SQL Server and Postgres does not have clustered indexes to begin with. (plus it's about dropping an index, not about renaming it) – a_horse_with_no_name Dec 3 '18 at 12:05

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.