Announcement

Symphony's issue tracker has been moved to Github.

Issues are displayed here for reference only and cannot be created or edited.

Browse

Closed#196: Each delegate requires an SQL query

Hot on the heels of my changes to cut DS queries, the second biggest creator of queries is the ExtensionManager::notifyMembers method. For every delegate that fires during a page’s lifecycle, an SQL query is made to return any enabled extensions which subscribe to the specific delegate. For example:

# SELECT t1.*, t2.callback FROM `sym_extensions` as t1 LEFT JOIN `sym_extensions_delegates` as t2 ON t1.id = t2.extension_id WHERE (t2.page IN ('/frontend/', '*')) AND t2.delegate = 'FrontendParamsResolve' AND t1.status = 'enabled';

Because the sym_extensions_delegates table never gets above about 200 rows (when you have many extensions) these queries are lightning fast: 0.0003s on my local machine.

This could be done using a single SELECT query and storing the entire table in memory:

SELECT extension_id, page, delegate, callback FROM sym_extensions_delegates

The ExtensionManager would hold this as a multidimensional array in memory and the notifyMembers function would look up in this array rather than performing additional SQL queries.

Fewer queries does not necessarily dictate a performance gain some testing would be required to assess the memory usage of both to ascertain which provides the most optimised experience.

I’ve found an interested article about caching mechanism. Have a look.

Good spot. Although not generic, Symphony’s core uses a similar method in the FieldManager and ExtensionManager classes by pooling instantiated objects. I’m suggesting increasing the scope of this cache to include not only instantiated Extensions, but also the delegates to which they subscribe.

This issue is closed.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details