Gellery Optimization Tutorial
How to Optimize Gallery
Very often Gallery2 (2.3 branch) has problems with slow MySQL queries. Generally slow queries mean slow page loading and server overloading. That's why such issues should be addressed as soon as possible.
In this article we will address the two most common problems - large sizes of CacheMap and SessionMap tables. By default these tables will have the prefix g2_ in front and they are responsible for content caching and user sessions storage.
We will start with the CacheMap table first. Generally caching is good but sometimes the complex Gallery2 engine makes it slower / more resource demanding to retrieve the content from the cache then to regenerate it. To solve this issue two things have to be done:
- Log in your Gallery2 admin panel and go to Performance under Admin Options, Gallery. Choose 'No acceleration' both for Guest Users and Registered Users.
- In the admin panel again, go to Maintenance under Admin Options, Gallery. For the task name 'Delete database cache' click on 'run now'.
Now we will proceed with the SessionMap table by completing the steps below:
- In Gallery2 admin panel go to General under Admin Options, Gallery. Under the Session Settings set to 15 minutes both Session Settings and Inactivity Timeout. You don't have to change the settings for Site Administration Session Timeout to a lower value because it may log you out too frequently.
- In the admin panel again, go to Maintenance under Admin Options, Gallery and for 'Delete user sessions' click on the action 'run now'.
The above steps will ensure that all current user sessions are deleted and are not stored for more than 15 minutes in the future. This will prevent future slow queries for the table SessionMap.
If you have followed the above steps, your slow MySQL queries problems should be resolved without sacrificing any of the Gallery2 functionalities.