[US EN]
Interactive CLI tool to identify and run VACUUM (or VACUUM FULL) on fragmented PostgreSQL tables, based on usage statistics.
This project helps maintain PostgreSQL databases by:
- Identifying fragmented tables based on dead tuples and size.
- Analyzing table statistics directly from the database.
- Safely executing
VACUUMorVACUUM FULLoperations interactively.
- 📊 Automatic analysis of tables with high fragmentation rates.
- 🧠 CLI interaction with intuitive prompts via
inquirer. - 🔐 Secure configuration through environment variables.
- 📄 Informative logs to track analyzed and processed tables.
- 🔁 Support for both
VACUUMandVACUUM FULL, with confirmation prompts.
├── config.js # Configuration and .env reader
├── index.js # Entry point and user interaction
├── TableAnalyzer.js # Logic for analyzing table stats
├── VacuumEngine.js # Executes VACUUM on selected tables
├── .env.example # Sample environment file
├── .gitignore # Ignores node_modules, .env, etc.
└── package.json # Project metadata and dependencies
- Node.js >= 16.x
- Accessible PostgreSQL database
- Sufficient privileges to run
VACUUM
git clone https://github.com/seu-usuario/seu-repositorio.git
cd seu-repositorio
npm install
cp .env.example .envEdit the .env file and insert your PostgreSQL connection string:
DATABASE_URL=postgres://user:password@localhost:5432/your_databasenode src/index.jsYou will be guided through prompts to:
- List fragmented tables.
- Choose between
VACUUMorVACUUM FULL. - Confirm execution before running.
? List fragmented tables? (Y/n)
? Use VACUUM FULL? (y/N)
? Confirm VACUUM execution? (Y/n)
- Be cautious in production.
VACUUM FULLlocks the table. - Ensure your DB user has permission to run
VACUUM.
Feel free to open issues or Pull Requests. Suggestions are welcome!
This project is licensed under the MIT License.
Questions or want to contribute?
[BR PT-BR]
Ferramenta interativa de linha de comando para identificar e executar VACUUM (ou VACUUM FULL) em tabelas fragmentadas de um banco de dados PostgreSQL, com base em estatísticas de uso.
Este projeto tem como objetivo facilitar a manutenção de bancos PostgreSQL, permitindo:
- Identificar tabelas fragmentadas com base em tuplas mortas e tamanho mínimo.
- Analisar estatísticas das tabelas diretamente do banco.
- Executar operações de
VACUUMouVACUUM FULLde forma segura e interativa.
- 📊 Análise automática de tabelas com alto percentual de fragmentação.
- 🧠 Interação via CLI com prompts intuitivos usando
inquirer. - 🔐 Configuração segura por meio de variáveis de ambiente.
- 📄 Logs informativos para rastrear o que foi analisado e processado.
- 🔁 Suporte ao uso de
VACUUMeVACUUM FULLcom confirmação do usuário.
├── config.js # Configuração e leitura do .env
├── index.js # Ponto de entrada e interface com o usuário
├── TableAnalyzer.js # Lógica de análise das tabelas
├── VacuumEngine.js # Execução do VACUUM nas tabelas selecionadas
├── .env.example # Exemplo de configuração de ambiente
├── .gitignore # Ignora node_modules, .env etc.
└── package.json # Dependências e metadados do projeto
- Node.js
pg— Cliente PostgreSQLdotenv— Variáveis de ambienteinquirer— Interface interativa no terminal
- Node.js >= 16.x
- Banco de dados PostgreSQL acessível
- Permissões adequadas para executar
VACUUM
git clone https://github.com/seu-usuario/seu-repositorio.git
cd seu-repositorio
npm install
cp .env.example .envEdite o arquivo .env e adicione sua string de conexão PostgreSQL:
DATABASE_URL=postgres://usuario:senha@localhost:5432/seu_banconode src/index.jsVocê será guiado por perguntas no terminal para:
- Listar tabelas fragmentadas.
- Escolher o tipo de
VACUUMa aplicar. - Confirmar antes da execução.
? Deseja listar as tabelas fragmentadas? (Y/n)
? Deseja usar VACUUM FULL? (y/N)
? Confirmar execução do VACUUM? (Y/n)
- Use com cautela em produção, especialmente ao usar
VACUUM FULL, pois ele bloqueia a tabela. - Certifique-se de que o usuário de banco tem permissões para executar
VACUUM.
Sinta-se à vontade para abrir issues ou Pull Requests! Sugestões e melhorias são bem-vindas.
Este projeto está licenciado sob a MIT License.
Caso tenha dúvidas ou queira contribuir de outra forma, entre em contato: