Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,219 of 9,219 pages
About the help in other languages
All help pages

Node lists leave out SELECT DISTINCT where no join can repeat a node

Read this page if you upgrade to the 6.0.15 line and read your database's slow log, compare query plans, or run code of your own that builds on the SQL of eZContentObjectTreeNode. From 3 December 2026 the node list…

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/bc/6.0/node-list-distinct.md

On this page

Node lists leave out SELECT DISTINCT where no join can repeat a node

Read this page if you upgrade to the 6.0.15 line and read your database's slow log, compare query plans, or run code of your own that builds on the SQL of eZContentObjectTreeNode. From 3 December 2026 the node list queries (fetch( 'content', 'list' ), 'tree', their counts, subTreeByNodeID(), subTreeCountByNodeID(), subTreeMultiPaths()) ask for SELECT DISTINCT only where a join in the query can give a node more than one row. The guide Content node lists has the full rule, the proof and the measurements; German: Listen von Inhaltsknoten.

In short

What changedThe plain node list (the four tables ezcontentobject_tree, ezcontentobject, ezcontentclass, ezcontentobject_name, conditions in WHERE only) is SELECT ... instead of SELECT DISTINCT ..., and its count is COUNT(*) instead of COUNT(DISTINCT ezcontentobject_tree.node_id). A sort by an attribute, the class name or a state, an attribute filter on an attribute or the class name, any extended attribute filter, a GroupBy, and a Group or StateGroup limitation in the user's read policies keep DISTINCT. New setting site.ini [ContentSettings] NodeListDistinct=auto (always restores the old queries).
WhyDISTINCT removed nothing from the plain list (each node meets one object, one class and one name row), but made MariaDB and MySQL collect every matching row in a temporary table before the sort and the limit. A forum's previous/next lookup took 1.85 s on average in the slow log; without DISTINCT it takes 1 to 2 ms.
Who is affectedEvery site, without anything to do: the lists hold the same nodes in the same order with the same counts. Only nodes that tie on every sort key may come in another order (no setting ever fixed that order). Code that parses or rewrites the generated SQL and expects SELECT DISTINCT must accept SELECT.
How to checkNothing to check. In the slow log the node lists no longer start with SELECT DISTINCT; EXPLAIN of a plain list no longer shows Using temporary for the duplicate removal. php bin/php/console exp:ini get site.ini/ContentSettings/NodeListDistinct global prints auto.
How to go backphp bin/php/console exp:ini set site.ini/ContentSettings/NodeListDistinct always global (or a siteaccess scope), then php bin/php/ezcache.php --clear-tag=ini, reload PHP-FPM or exp:velocity restart, and --clear-id=content. Any value other than auto counts as always.
Upgrade stepNone. The setting comes with settings/site.ini; no database change.

Lists that page through ties

A list sorted only by a key that many nodes share (published of an import, priority 0) and read page by page (Offset) could return a node on two pages, or none, before as now, whenever the database chose another plan. With DISTINCT left out it may choose another plan than it used to. Give such a list a unique last sort key:

fetch( 'content', 'list', hash( 'parent_node_id', 2,
                                'sort_by', array( array( 'published', false() ), array( 'node_id', false() ) ),
                                'offset', $offset, 'limit', 20 ) )

Engines

MySQL/MariaDB, PostgreSQL, SQLite and Oracle run the same SQL; the result sets of both settings were compared on MariaDB 11.4, PostgreSQL 17 and 18 and SQLite (and the decision without a database). On MongoDB subTreeByNodeID() and subTreeCountByNodeID() are aggregation pipelines that never had DISTINCT; subTreeMultiPaths() goes through the SQL adapter, which reads the query with and without DISTINCT; the same comparison ran on MongoDB 7.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x