Ever since the beginning, WPML performed way too many database accesses. If your site was on a busy shared host, you might have noticed a serious drop in performance with WPML. Version 1.3.3 fixes this, by eliminating 90% of these queries.
You can grab the first beta release and try it. We’re already using it on wpml.org and it looks fine.
There are no new functions (a few minor bug fixes did make it in) and if you’re running from a very fast server, you may not notice any change. However, busy sites running on shared hosting will see an immediate improvement in site response.
Caching and prefetching for language information
WPML now includes a new caching class which is responsible for holding information that’s used more than once. Before, whenever any function needed something, it asked the database server. Now, it asks the cache which only accesses the database if it doesn’t yet have that information.
Additionally, some pages like the blog page (or home) contain multiple posts. WPML now gets the language information for all posts in one database access and saves in it the cache for when it’s needed.
The results are:
- Before language caching — 160 queries
- After caching — 17 queries
Caching for CMS navigation
We thought that there’s a problem with the language information, but the CMS navigation actually took even us by surprise.
To generate the navigational elements in wpml.org, it took no less than 250 database queries. There’s a good reason for that too. WPML’s sidebar and top navigation are complex elements. They go up and down the page hierarchy, determining what needs to be displayed.
Caching for those is now done on the HTML level. E.g., the navigation elements are produced once and then saved. Subsequent page displays will require just one single call to fetch from the cache.
It turns out that we’re not alone. If you’re using a different plugin for drop down menus, check how many database accesses it’s causing. You’re in for a surprise…
How to test database queries
If you’re wondering how to test the number of database queries WordPress does, look no further than the great Debug Queries plugin. It will show you the accesses, how long they actually took and the breakdown between PHP processing and database access time.
Let us know how it’s going. We’re looking to release WPML 1.3.3 soon and want to know if there are any problems.