You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maksim Myskov (Jira)" <ji...@apache.org> on 2024/01/31 10:58:00 UTC

[jira] [Reopened] (IGNITE-21384) Initialize all rows with new column's default value

     [ https://issues.apache.org/jira/browse/IGNITE-21384?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maksim Myskov reopened IGNITE-21384:
------------------------------------

Reopened due to changed circumstances. According to [~slukyanov] , the performance penalty is not a no-go factor for now. It can be optimized in the future.

> Initialize all rows with new column's default value
> ---------------------------------------------------
>
>                 Key: IGNITE-21384
>                 URL: https://issues.apache.org/jira/browse/IGNITE-21384
>             Project: Ignite
>          Issue Type: New Feature
>            Reporter: Maksim Myskov
>            Priority: Major
>              Labels: ignite-3
>
> In case of adding a new column with a default value specified (for example: ALTER TABLE ADD COLUMN col INT DEFAULT 10), all existing rows (that were added before "alter table") must be initialized with a new value.
> h3. Current behaviour
> The default value of a column is evaluated on read.
> h3. Motivation
> This is a pre-requisite for adding arbitrary expressions as default values. Let's imagine a simple case:
> {code:sql}
> ALTER TABLE ADD COLUMN modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP
> {code}
> With the current behavior for all existing rows the value of "modified" column will be evaluated on every read.
> Many DBs use the proposed behavior:
>  * PostgreSQL
>  * CockroachDB
>  * Yugabyte
> For example, from PostgreSQL [docs|https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-NOTES]:
> {noformat}
> Adding a column with a volatile DEFAULT or changing the type of an existing column will require the entire table and its indexes to be rewritten.
> {noformat}
> h3. Downsides
> Adding a new column with a default value will be a much more expensive operation and can take a significant time on large tables



--
This message was sent by Atlassian Jira
(v8.20.10#820010)