1.9 Practical Tips
Right after a restart, things are slow. When a server has just started, the buffer pool is empty. The buffer pool is data in memory, so it is reset every time the database starts. The first queries right after a restart must load all the pages they need from disk and put them in the buffer pool, so they are slow, and they get faster as frequently used pages accumulate in the buffer pool over time. This is why a service restarted after maintenance runs slowly for a while.
When you run the same query twice, the second run is faster. This is because the pages needed were loaded into the buffer pool during the first run. So when comparing performance, measure repeatedly. Alternatively, it is also recommended to measure performance by the number of pages read rather than by time.
Adding memory can make the database faster overall. A larger memory lets the buffer pool hold more pages, which raises the cache hit ratio. However, in a system that already has enough memory and a high hit ratio, the effect is almost nil.
TIP A database reads and writes in pages, not records. And a page that has been referenced once is kept in the buffer pool and reused as much as possible.