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#408: Count of entries in SectionManager is never used (performance)

I fell into a trance-like state during a recent query debugging session and discovered a query that can be safely removed that really improves performance.

http://github.com/symphonycms/symphony-2/blob/master/symphony/lib/toolkit/class.sectionmanager.php#L34

The entry_count that is created here is never used in the system at all. Search the source and weep.

By means of example the generated query might look like this:

SELECT `s`.*, count(`e`.`id`) as `entry_count`      
FROM `sym_sections` AS `s`
LEFT JOIN `sym_entries` AS `e` ON `s`.id = `e`.`section_id`
WHERE `s`.`id` = '123'
GROUP BY `s`.id

When my entry_count returned about 20,000 entries the query time was about 70ms. Not that slow, but consider this query running every time a new section is queried (at least once per new DS).

I removed the count completely:

SELECT `s`.*
FROM `sym_sections` AS `s`
WHERE `s`.`id` = '123'

And query time snapped down to 0.5ms.

My page was on average 1.1s before, and 0.3s afterwards.

After some more testing it seems the performance gains are ever so slight on most builds. However they are notable when you have sections that have many thousands of entries.

Rolled this into this commit

Rock and roll, nice one.

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