What's new in XenForo Media Gallery 2.3?
Our primary focus for XenForo Media Gallery 2.3 is performance. Now, the Media Gallery is performant for most use cases, but there's an upper limit in terms of the size of your gallery which can determine just how performant it is. The queries that Media Gallery executes to return media items in various contexts are necessarily complex. We have to take into account a variety of different states including general permissions, category permissions, album privacy settings and individual media and album states.
Over the years we have added features which can mitigate the issues to an extent including the ability to limit the media lists to a maximum time period, for example, only displaying the most recent 12 months of media items.
Aside from the general complexity of the unit of work each query does, one of the biggest performance degradations is caused by MySQL's handling of large offsets. In a recent test consisting of over 45,000 pages of media (1 million media items!) trying to load page 45,252 resulted in an over 30 second delay to load the page.
Deferred joins
Enter "deferred joins"! This is actually a new feature in the core of XenForo, albeit currently only used within Media Gallery. For the developers amongst you, all it really means is you will call $finder->fetchDeferred() rather than $finder->fetch(), and for the non-developers amongst you, what it means is "slow query go fast"
Behind the scenes what actually happens is rather than executing a single query, it executes two! Which may seem counter-intuitive but bear with me. The first query simply aims to fetch the applicable IDs for the conditions and page you are on which is fast because it uses the primary key, whereas the second query fetches all of the data applicable with all of the joins but matching those specific IDs fetched from the first query.
To cut a very long story short, if you take the page 45,252 example from above, this same query reduced from over 30 seconds to only 2 seconds. While 2 seconds might still seem a little on the high side, this is a 93% decrease from before, and it's only as high as it is because of the high page number. The upshot is that the sheer majority of those 45,000+ pages will now be remarkably faster to load than before. This will not only massively decrease frustration of your users, but it will significantly increase the likelihood of these pages being crawled by search engines and dramatically decrease the load on your database.
What else is new?
Much like Resource Manager, Media Gallery too benefits from the addition of featured content, image optimization, webhooks and search suggestions.