-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add indexes to improve performance of some queries #226
Changes from all commits
d2a6565
56a61c5
5402c52
f4378d6
e7941cd
a3b8800
5e30ef6
0343da8
d0eefbd
1265510
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ class ContentDataProviderRepository implements DataProviderRepositoryInterface | |
{ | ||
public const CONTENT_RICH_ENTITY_ALIAS = 'entity'; | ||
public const LOCALIZED_DIMENSION_CONTENT_ALIAS = 'localizedContent'; | ||
public const UNLOCALIZED_DIMENSION_CONTENT_ALIAS = 'unlocalizedContent'; | ||
|
||
/** | ||
* @var ContentManagerInterface | ||
|
@@ -404,6 +403,8 @@ protected function setSortByJoins(QueryBuilder $queryBuilder): array | |
*/ | ||
protected function appendRelation(QueryBuilder $queryBuilder, string $relation, array $values, string $operator, string $alias): array | ||
{ | ||
$queryBuilder->distinct(); // TODO remove distinct and replace joins with subselect filter see: https://github.com/sulu/SuluContentBundle/pull/226 | ||
|
||
switch ($operator) { | ||
case 'or': | ||
return $this->appendRelationOr($queryBuilder, $relation, $values, $alias); | ||
|
@@ -461,15 +462,13 @@ protected function createEntityIdsQueryBuilder(string $locale): QueryBuilder | |
: DimensionContentInterface::STAGE_LIVE; | ||
|
||
return $this->entityManager->createQueryBuilder() | ||
// no distinct used here else it would hurt performance of the query: https://github.com/sulu/SuluContentBundle/pull/226 | ||
// distinct only added in `appendRelation` methods where it is required | ||
->select(self::CONTENT_RICH_ENTITY_ALIAS . '.' . $this->getEntityIdentifierFieldName() . ' as id') | ||
->distinct() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This hurts the performance a lot but is not necessary. All joins of filters should be created the way that no distinct is required here else we will run into a lot of performance issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should in future have a look at the queries that we not longer have todo |
||
->from($this->contentRichEntityClass, self::CONTENT_RICH_ENTITY_ALIAS) | ||
->innerJoin(self::CONTENT_RICH_ENTITY_ALIAS . '.dimensionContents', self::LOCALIZED_DIMENSION_CONTENT_ALIAS) | ||
->andWhere(self::LOCALIZED_DIMENSION_CONTENT_ALIAS . '.stage = (:stage)') | ||
->andWhere(self::LOCALIZED_DIMENSION_CONTENT_ALIAS . '.locale = (:locale)') | ||
->innerJoin(self::CONTENT_RICH_ENTITY_ALIAS . '.dimensionContents', self::UNLOCALIZED_DIMENSION_CONTENT_ALIAS) | ||
->andWhere(self::UNLOCALIZED_DIMENSION_CONTENT_ALIAS . '.stage = (:stage)') | ||
->andWhere(self::UNLOCALIZED_DIMENSION_CONTENT_ALIAS . '.locale IS NULL') | ||
->setParameter('stage', $stage) | ||
->setParameter('locale', $locale); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created an issue for this. here some improvements could be made: #227