PART 1
Use InnoDB instead on MyISAM.
Using InnoDB as the storage engine for your MySQL database offers several advantages that make it a preferred choice for many applications, including MMORPG servers:
1. ACID Transactions:
InnoDB supports ACID (Atomicity, Consistency, Isolation, Durability) transactions. This means that database transactions are processed in a way that ensures they are either fully completed or fully rolled back, maintaining data integrity and consistency.
2. Referential Integrity:
InnoDB supports foreign keys and enforces referential integrity between tables. This ensures that relationships between tables are maintained, preventing orphaned records and ensuring data consistency.
3. Concurrency and Multi-Versioning:
InnoDB handles concurrent transactions efficiently through multi-versioning. Multiple transactions can be executed simultaneously without locking the entire database, allowing for high levels of concurrency. InnoDB uses row-level locking, enabling multiple transactions to access different rows in the same table simultaneously.
4. Crash Recovery:
InnoDB is designed to be very resilient. In the event of a crash, InnoDB automatically performs crash recovery, bringing the database back to a consistent state without data corruption.
5. Automatic Deadlock Detection and Resolution:
InnoDB can detect deadlocks and automatically resolve them by rolling back a transaction that is causing the deadlock, allowing other transactions to proceed.
6. Storage Efficiency:
InnoDB uses a clustered index (the primary key) for data storage. This clustered index organization can lead to more efficient use of disk space and faster data retrieval for primary key lookups.
7. Online Backup and Table-level Locking:
InnoDB supports online backup using tools like mysqldump or Percona XtraBackup. Additionally, it supports both table-level and row-level locking, allowing for a balance between data integrity and performance optimization.
8. Support for Full-Text Search:
InnoDB supports full-text search capabilities, allowing you to perform complex searches on textual data efficiently.
9. Community and Documentation:
InnoDB is well-supported, widely used, and has extensive documentation and community support. If you encounter issues or need help, there are ample resources available.
In summary, InnoDB is a robust and feature-rich storage engine that provides excellent support for transactions, concurrency, data integrity, and crash recovery. These features make it a solid choice for applications like MMORPG servers where data consistency, concurrent access, and reliability are crucial. However, the choice of storage engine should be based on your specific application requirements and workload characteristics.
Query for converting all MyISAM database tables to InnoDB.
SET @DATABASE_NAME = 'l2jmobius';
SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE=InnoDB;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `ENGINE` = 'MyISAM'
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC
Continue with Part 2 to see how to change MySQL configurations, including how to set default engine to InnoDB.