A database can be optimized by various means:
Creating indexes
indexes
Putting in memory
memory
Using SSD (Solid-State Drive)
SSD
Alternatively processes can run in the background to avoid timeouts.