-- Minimales Cleanup-Script
-- Entfernt alle INDEX außer PRIMARY KEY und UNIQUE Keys

USE trainingsdiary;

-- 1. Status vor Cleanup
SELECT '=== STATUS VOR CLEANUP ===' as info;
SELECT 
    TABLE_NAME,
    COUNT(*) as key_count
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary' 
GROUP BY TABLE_NAME
ORDER BY key_count DESC;

SELECT 
    COUNT(*) as total_keys_before
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary';

-- 2. Alle nicht-essentiellen INDEX entfernen
-- Behalte nur PRIMARY KEY und UNIQUE Keys

-- Alle INDEX außer PRIMARY und UNIQUE entfernen
-- Verwende SHOW INDEX um die echten INDEX-Namen zu sehen

SELECT '=== ENTFERNE ÜBERFLÜSSIGE INDEX ===' as info;

-- Member-Tabelle: Alle INDEX außer PRIMARY entfernen
SELECT '=== MEMBER TABELLE ===' as info;
SHOW INDEX FROM member;

-- User-Tabelle: Alle INDEX außer PRIMARY entfernen  
SELECT '=== USER TABELLE ===' as info;
SHOW INDEX FROM user;

-- Clubs-Tabelle: Alle INDEX außer PRIMARY entfernen
SELECT '=== CLUBS TABELLE ===' as info;
SHOW INDEX FROM clubs;

-- User_Club-Tabelle: Alle INDEX außer PRIMARY entfernen
SELECT '=== USER_CLUB TABELLE ===' as info;
SHOW INDEX FROM user_club;

-- Log-Tabelle: Alle INDEX außer PRIMARY entfernen
SELECT '=== LOG TABELLE ===' as info;
SHOW INDEX FROM log;

-- Diary_Dates-Tabelle: Alle INDEX außer PRIMARY entfernen
SELECT '=== DIARY_DATES TABELLE ===' as info;
SHOW INDEX FROM diary_dates;

-- Participants-Tabelle: Alle INDEX außer PRIMARY entfernen
SELECT '=== PARTICIPANTS TABELLE ===' as info;
SHOW INDEX FROM participants;

-- Activities-Tabelle: Alle INDEX außer PRIMARY entfernen
SELECT '=== ACTIVITIES TABELLE ===' as info;
SHOW INDEX FROM activities;

-- 3. Status nach Cleanup
SELECT '=== STATUS NACH CLEANUP ===' as info;
SELECT 
    TABLE_NAME,
    COUNT(*) as key_count
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary' 
GROUP BY TABLE_NAME
ORDER BY key_count DESC;

SELECT 
    COUNT(*) as total_keys_after
FROM INFORMATION_SCHEMA.STATISTICS 
WHERE TABLE_SCHEMA = 'trainingsdiary';

-- 4. Zusammenfassung
SELECT '=== ZUSAMMENFASSUNG ===' as info;
SELECT 
    'Minimales Cleanup abgeschlossen. Überprüfen Sie die Anzahl der Keys oben.' as message;
