From: | Hellmuth Vargas <hivs77(at)gmail(dot)com> |
---|---|
To: | Lista Postgres ES <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Alter varchar column size recrea índice? |
Date: | 2022-02-08 10:15:43 |
Message-ID: | CAN3Qy4pB11oE8yAF0xawCB0idF7TfnkcZSQN0EsHwHH3Q+nh7Q@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola lista
Solo estoy preguntando por el caso particular donde vamos a alterar el
tamaño de un campo varchar:
varchar(n) -> varchar(m) donde m>n
Osea, en principio, no se altera la información almacenada
El mar., 8 de febrero de 2022 5:06 a. m., Hellmuth Vargas <hivs77(at)gmail(dot)com>
escribió:
>
> Hola lista
>
> Leyendo por ahí en el siguiente post
>
>
>
> https://www.linkedin.com/posts/somdyuti-paul-042aa27_rds-postgresql-aws-activity-6896664452180131840-QZGN
>
>
> Expone que cuando se altera el tamaño de una columna varchar INDEXADA
> internamente se recrear el índice asociado.... Ojo solo estamos cambiando
> el tamaño... Que opinan?
>
> Adjunto el comentario
>
> Postgres Diaries #5 Does Postgres acquire Access Exclusive Lock when
> changing the length of a VARCHAR Column? No. It does not take ACCESS
> EXCLUSIVE lock on the table as it does not rewrite the entire table (unlike
> changing the datatype of a column or adding new column, etc), but it does
> try to rebuild/rewrite any index on the column which we are changing (and
> this may increase the time it takes to run the alter). Example- Say there
> is a table TEST (id1 integer, id2 varchar(64)). We want to increase id2
> from varchar(64) to varchar(128) and there is an index "idx_test_id2" on
> id2. The steps to increase VARCHAR length in the fastest possible way with
> no production database impact are:- 1. set lock_timeout='5s'; 2. drop index
> idx_test_id2; 3. set lock_timeout='5s'; 4. ALTER TABLE test ALTER COLUMN
> id2 TYPE varchar(128); 5. set maintenance_work_mem='<high value>'; 6.
> create index concurrently idx_test_id2 on test(id2);
>
From | Date | Subject | |
---|---|---|---|
Next Message | Francisco Olarte | 2022-02-08 11:22:02 | Re: Réplica lenta después de purgado en master |
Previous Message | Ruben Fitó | 2022-02-08 10:14:16 | Re: Réplica lenta después de purgado en master |