On 06/04/2016 23:30, [email protected] wrote:
Olá pessoal, tudo bem?
Vamos ver se vocês conseguem ajudar....


Possuo em minha DB a seguinte tabela:

        CREATE TABLE gorfs.inode_segments

        (

           st_ino "gorfs"."ino_t" NOT NULL, -- Inode number the segment
        belongs to. alongside segment_index, it forms the table's
        primary key to ensure uniqueness per relevant scope

           segment_index "gorfs"."pathname_component" NOT NULL, -- See
        st_no's column description for further details. The meaning of
        this column varies based on the host inode type:...

           st_ino_target "gorfs"."ino_t", -- Target inode number.
        Meaningful for directory inode segments (objects in the directory)

           full_path "gorfs"."absolute_pathname", -- Exploded absolute
        canonical path for quick lookups. Meaningful only for directory
        inode segments (objects in the directory)

        *segment_data "bytea", -- Actual data segment. Meaningful only
        for S_IFLNK and S_IFREG....*

           CONSTRAINT pk_inode_segments PRIMARY KEY ("st_ino",
        "segment_index"),

           CONSTRAINT fk_host_inode_must_exist FOREIGN KEY (st_ino)

               REFERENCES gorfs.inodes (st_ino) MATCH SIMPLE

               ON UPDATE NO ACTION ON DELETE NO ACTION,

           CONSTRAINT fk_target_inode_must_exist FOREIGN KEY (st_ino_target)

               REFERENCES gorfs.inodes (st_ino) MATCH SIMPLE

               ON UPDATE NO ACTION ON DELETE NO ACTION,

           CONSTRAINT uc_no_duplicate_full_paths UNIQUE ("full_path"),

           CONSTRAINT cc_only_root_can_be_its_own_parent CHECK
        ("st_ino_target" IS NULL OR "st_ino"::bigint <>
        "st_ino_target"::bigint OR "st_ino"::bigint = 2)

        )


Podem notar na coluna *"segment_data"* - Esta coluna armazena todos os
arquivos dos usuários, tais como: imagens, pdfs, docs, etc

Esta coluna será migrada para um servidor NFS, sendo assim, todos os
blobs serão removidos da DB.

Basicamente a migracão consiste em setar NULL a row, uma vez que os
dados foram migrados com sucesso.

        UPDATE gorfs.inode_segments SET segment_data = NULL WHERE
        batch_number = 0



O tamanho total de minha DB é: 2 TB
O tamanho total da tabela gorfs.inode_segments é: 1698 GB
(Comando: SELECT pg_size_pretty(
pg_total_relation_size('gorfs.inode_segments'));)

*Pergunta:*
Quando a coluna for setada como NULL (não será de uma vez só... será
gradativamente), eu vou ter espaco liberado na hora? Ou é preciso fazer
alguma outra coisa?

Sim, você precisa fazer um vacuum full da tabela ou um dump/restore, ou recriá-la de outra forma como criando uma nova tabela temporária, apaga a antiga e renomeia a nova.

Aliás, eu não faria seu update porque ele possívelmente vai tomar um tempo enorme - eu criaria uma nova tabela só com as colunas que interessam e depois apagaria a antiga.

Vou ter que fazer um DUMP da DB (uma vez que toda coluna segment_data
estiver como NULL) ?

Não precisa fazer do banco todo se só te interessa uma tabela.

[]s
Flavio Gurgel
_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a