Entity query with condition and sorting by a field from the same table makes duplicated joins.
My investigating:
Class 'Drupal\Core\Entity\Query\Sql\Query' method getTables() always returns new 'Drupal\Core\Entity\Query\Sql\Tables' object.
In this case, the Tables object doesn't have actual state of 'entityTables' property, and adds duplicated joins.
Because ensureEntityTable() method needs correct 'entityTables' property, for building joins.
Method getTables() is called seperatly when sort is added and conditions are compiled (getTables() method can be called several times during conditions' compiling).
My propose:
I think, getTables() method should write Tables object into 'tables' property. And in next call it should return Tebles object from 'tables' property instead of creating new object.
Or I don't understand somethings, and don't see reason why getTables() returns new object.