Skip to content
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

Merged
merged 10 commits into from
Oct 4, 2022

Conversation

alexander-schranz
Copy link
Member

@alexander-schranz alexander-schranz commented Oct 3, 2022

While having a look at our projects recipe bundle. I got hit by very slow queries.

Before: ~2023 ms
After: ~20ms (without filters, with tag or category filters ~1300ms see #227 for more improvements)

@alexander-schranz alexander-schranz added the Performance Problems with performance label Oct 3, 2022
@@ -460,7 +459,6 @@ protected function createEntityIdsQueryBuilder(string $locale): QueryBuilder

return $this->entityManager->createQueryBuilder()
->select(self::CONTENT_RICH_ENTITY_ALIAS . '.' . $this->getEntityIdentifierFieldName() . ' as id')
->distinct()
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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 distinct as it seems have bad effects on this kind of queries. See #227

@@ -402,6 +401,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
Copy link
Member Author

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

@coveralls
Copy link

coveralls commented Oct 3, 2022

Pull Request Test Coverage Report for Build 3177569846

  • 10 of 10 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 3177393104: 0.0%
Covered Lines: 1809
Relevant Lines: 1809

💛 - Coveralls

@alexander-schranz alexander-schranz marked this pull request as ready for review October 3, 2022 21:23
@wachterjohannes wachterjohannes merged commit 9e81f56 into sulu:0.6 Oct 4, 2022
@alexander-schranz alexander-schranz deleted the feature/query-performance branch October 4, 2022 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Problems with performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants