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

Improve smart content filter query #227

Open
alexander-schranz opened this issue Oct 3, 2022 · 0 comments
Open

Improve smart content filter query #227

alexander-schranz opened this issue Oct 3, 2022 · 0 comments
Labels
Performance Problems with performance

Comments

@alexander-schranz
Copy link
Member

alexander-schranz commented Oct 3, 2022

The current smart content filter queries can be very slow because of usage of distinct:

With Distinct and Join 1.37s:

SELECT DISTINCT k0_.id AS id_0,

k1_.workflowPublished as workflow_published_1

FROM kgr_recipes k0_

INNER JOIN kgr_recipe_dimension_contents k1_ ON k0_.id = k1_.recipeId

INNER JOIN kgr_recipe_dimension_content_excerpt_categories k3_ ON k3_.recipe_dimension_content_id = k1_.id 

WHERE k1_.stage = 'live' AND k1_.locale = 'de'
 AND k3_.category_id IN (165, 144)

-- AND (
--    SELECT k3_.category_id FROM kgr_recipe_dimension_content_excerpt_categories k3_
--    WHERE k3_.recipe_dimension_content_id = k1_.id AND k3_.category_id IN (165, 144)
--    LIMIT 1
-- ) != 0

ORDER BY k1_.workflowPublished DESC LIMIT 33

Without Join and without distinct 83ms:

SELECT k0_.id AS id_0,

k1_.workflowPublished as workflow_published_1

FROM kgr_recipes k0_

INNER JOIN kgr_recipe_dimension_contents k1_ ON k0_.id = k1_.recipeId


-- INNER JOIN kgr_recipe_dimension_content_excerpt_categories k3_ ON k3_.recipe_dimension_content_id = k1_.id -- AND k3_.category_id IN (165, 144)

WHERE k1_.stage = 'live' AND k1_.locale = 'de'
-- AND k3_.category_id IN (165, 144)

AND (
  SELECT k3_.category_id FROM kgr_recipe_dimension_content_excerpt_categories k3_
  WHERE k3_.recipe_dimension_content_id = k1_.id AND k3_.category_id IN (165, 144)
  LIMIT 1
) != 0

ORDER BY k1_.workflowPublished DESC LIMIT 33

This impacts:

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

No branches or pull requests

1 participant