0

PostgreSQL 12 enables generated columns. Is there an overhead of using a generated column? If yes what is it?

Is table locked for read/write when such column is added?

gshilin
  • 647
  • 14
  • 23
  • See this Stack DBA question which is almost identical to this one: https://dba.stackexchange.com/questions/166792/postgresql-generated-columns – Tim Biegeleisen Mar 16 '21 at 15:46
  • no , this is a great feature – eshirvana Mar 16 '21 at 15:46
  • @TimBiegeleisen The question mentioned by you is about "whether this generated column is supported". I'm asking about "what overhead will I get from such a column" – gshilin Mar 16 '21 at 15:51
  • 1
    Yes, the table is locked when you run an ALTER TABLE statement. –  Mar 16 '21 at 15:53
  • 1
    Currently Postgres only supports `STORED` generated columns which means the value is physically stored in the column. Overhead is incurred if the row changes and the value has to be recalculated. – Adrian Klaver Mar 16 '21 at 16:06
  • @a_horse_with_no_name doesn't alter command lock the table regardless? – eshirvana Mar 16 '21 at 16:54

0 Answers0