Initial commit
This commit is contained in:
36
scripts/database-maintenance.sql
Normal file
36
scripts/database-maintenance.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
-- Database maintenance and optimization script
|
||||
USE emergency_tracker;
|
||||
|
||||
-- Show current connection status
|
||||
SHOW STATUS LIKE 'Threads_connected';
|
||||
SHOW STATUS LIKE 'Threads_running';
|
||||
SHOW STATUS LIKE 'Max_used_connections';
|
||||
|
||||
-- Show current process list (active connections)
|
||||
SHOW PROCESSLIST;
|
||||
|
||||
-- Optimize tables for better performance
|
||||
OPTIMIZE TABLE users;
|
||||
OPTIMIZE TABLE admin_actions;
|
||||
|
||||
-- Update table statistics
|
||||
ANALYZE TABLE users;
|
||||
ANALYZE TABLE admin_actions;
|
||||
|
||||
-- Show table sizes
|
||||
SELECT
|
||||
table_name AS 'Table',
|
||||
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS 'Size (MB)'
|
||||
FROM information_schema.TABLES
|
||||
WHERE table_schema = 'emergency_tracker'
|
||||
ORDER BY (data_length + index_length) DESC;
|
||||
|
||||
-- Show connection limits
|
||||
SHOW VARIABLES LIKE 'max_connections';
|
||||
SHOW VARIABLES LIKE 'wait_timeout';
|
||||
SHOW VARIABLES LIKE 'interactive_timeout';
|
||||
|
||||
-- Recommended settings for connection management
|
||||
-- SET GLOBAL max_connections = 200;
|
||||
-- SET GLOBAL wait_timeout = 300;
|
||||
-- SET GLOBAL interactive_timeout = 300;
|
||||
Reference in New Issue
Block a user