Re: Adding a column with default value possibly corrupting a functional index.
От | Tom Lane |
---|---|
Тема | Re: Adding a column with default value possibly corrupting a functional index. |
Дата | |
Msg-id | 10285.1166326604@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: Adding a column with default value possibly corrupting a functional index. ("Rajesh Kumar Mallah" <mallah.rajesh@gmail.com>) |
Ответы |
Re: Adding a column with default value possibly corrupting a functional index.
|
Список | pgsql-admin |
"Rajesh Kumar Mallah" <mallah.rajesh@gmail.com> writes: > On 12/16/06, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> I think the proximate cause of the problem is that the function's >> SELECT is trying to use an index on the category_id column, >> and the REINDEX done by ALTER TABLE happens to rebuild the two indexes >> in the other order, such that the one on category_id isn't valid yet >> when the functional index is rebuilt. > why does ALTER TABLE ADD new_col int default 0 rebuilds > existing indexes ? Because it has to rewrite the whole table to insert the default value in every row. A REINDEX is way more efficient for recovering from that than any row-by-row update would be. >> I wonder whether we need to do something to actively prevent functions >> used in an index from querying the database? It's not too hard to >> imagine crashing the backend by playing this sort of game. > the game was seemingly fulfilling a requirement. dunno what > i should be doing now. It sorta looks to me like you're trying to get the effect of a materialized view --- have you looked at the techdocs pages about how to do those in Postgres? regards, tom lane
В списке pgsql-admin по дате отправления: