Skip to content
Snippets Groups Projects

Issue #2950869: Entity queries querying the latest revision very slow with lots of revisions

Open Issue #2950869: Entity queries querying the latest revision very slow with lots of revisions
1 unresolved thread
1 unresolved thread

Issue #2950869 by amateescu, alexpott, Fabianx, abhishek-anand, ravi.shankar, adam.weingarten, Timmy_Cos, Rashmisoni, bryanmanalo, pooja saraah, pratik, corneboele, matsbla, Wim Leers, mheip, mariancalinro, effulgentsia, Krzysztof Domański, lucassc: Entity queries querying the latest revision very slow with lots of revisions

Closes #2950869

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
482 482
483 483 if (!isset($this->latestRevisionIds[$entity_id][LanguageInterface::LANGCODE_DEFAULT])) {
484 484 $result = $this->getQuery()
485 ->latestRevision()
485 ->allRevisions()
486 486 ->condition($this->entityType->getKey('id'), $entity_id)
487 ->range(0, 1)
488 ->sort($this->entityType->getKey('revision'), 'DESC')
  • Comment on lines -485 to +488

    Not sure this change is not a BC, as per:

      public function latestRevision() {
        $this->allRevisions = TRUE;
        $this->latestRevision = TRUE;
        return $this;
      }
    
      public function allRevisions() {
        $this->allRevisions = TRUE;
        $this->latestRevision = FALSE;
        return $this;
      }

    So we should have still $this->latestRevision = TRUE.
    My proposal is to add just a ->range(0, 1) to it, i.e.:

    Suggested change
    485 ->allRevisions()
    486 ->condition($this->entityType->getKey('id'), $entity_id)
    487 ->range(0, 1)
    488 ->sort($this->entityType->getKey('revision'), 'DESC')
    485 ->condition($this->entityType->getKey('id'), $entity_id)
    486 ->range(0, 1)
    Edited by Dmitry Korkhau
  • Please register or sign in to reply
Please register or sign in to reply
Loading