I'm wondering when a table acquires an oid. Is it only when the transaction commits? Or does it have a hidden oid prior to commit? Especially in the context of a CREATE TABLE AS SELECT
.
PostgreSQL OID – When Does a Table Get an OID in PostgreSQL
ctasdatabase-internalspostgresql
Related Question
- Postgresql – Get TEXT value of a CLOB OID in Postgresql
- PostgreSQL 9.6 Beta1 – New Setting ‘remote_apply’ for Configuration Parameter ‘synchronous_commit’
- Postgresql – postgres backup for specific table with blob oid
- Postgresql – Not find the table of the oid
- PostgreSQL – Optimistic Locking Blocking Due to Locks
Best Answer
Table OIDs are assigned quite early in table creation, and are definitely present by the time the
CREATE TABLE
finishes (before xact commit), since the row is visible inpg_class
by then.The new
pg_class
row (and its oid) are not visible to concurrent transactions until commit, though.It's not clear why you care, though. It shouldn't matter.