Database Optimization
Optimize your database queries and structure for improved server performance.
Use Indexes
Query Optimization
- Select only needed columns.
- Use prepared statements.
- Avoid
SELECT *
in production code.
Batch Operations
Async Operations
- Use async DB calls (
MySQL.Async
,oxmysql:execute
) to avoid blocking the server thread. - Never use sync DB calls in production.
Connection Pooling
- Use OxMySQL or configure pool size in MySQL-Async.
Maintenance
- Regularly run
OPTIMIZE TABLE
andANALYZE TABLE
. - Backup your database frequently.
Troubleshooting
- Check server logs for slow query warnings.
- Use
mysql_debug 1
in server.cfg for query logging.