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 <hiv...@gmail.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);
>

Reply via email to