Enhance database performance diagnostics: Add detailed logging for unused primary key index and implement error handling for query statistics retrieval. Additionally, automate ANALYZE execution for affected tables after index creation to ensure PostgreSQL optimizes query performance. This improves clarity on index usage and enhances overall database performance management.
This commit is contained in:
@@ -125,13 +125,25 @@ async function main() {
|
||||
console.log(` Übersprungen: ${skipped}`);
|
||||
console.log(` Fehler: ${errors}\n`);
|
||||
|
||||
// ANALYZE ausführen, damit PostgreSQL die neuen Indizes berücksichtigt
|
||||
const tablesToAnalyze = [
|
||||
'falukant_data.knowledge',
|
||||
'falukant_data.inventory',
|
||||
'falukant_data.stock',
|
||||
'falukant_data.production',
|
||||
'falukant_data.director'
|
||||
];
|
||||
if (created > 0) {
|
||||
console.log('💡 Tipp: Führe ANALYZE aus, damit PostgreSQL die neuen Indizes berücksichtigt:');
|
||||
console.log(' ANALYZE falukant_data.knowledge;');
|
||||
console.log(' ANALYZE falukant_data.inventory;');
|
||||
console.log(' ANALYZE falukant_data.stock;');
|
||||
console.log(' ANALYZE falukant_data.production;');
|
||||
console.log(' ANALYZE falukant_data.director;\n');
|
||||
console.log('📊 Führe ANALYZE auf betroffenen Tabellen aus...\n');
|
||||
for (const table of tablesToAnalyze) {
|
||||
try {
|
||||
await sequelize.query(`ANALYZE ${table};`);
|
||||
console.log(` ✅ ANALYZE ${table};`);
|
||||
} catch (err) {
|
||||
console.log(` ⚠️ ${table}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
console.log('');
|
||||
}
|
||||
|
||||
await sequelize.close();
|
||||
|
||||
Reference in New Issue
Block a user