Skip to content

Conversation

@pmattmann
Copy link
Member

@pmattmann pmattmann commented Jan 18, 2025

It is not clear to me what the filter FilterEagerLoadingsExtension is supposed to do.
In our case, it ensures that the endpoint /camps/111/categories does not perform well.

The filter rebuilds the SQL
from:

select      ...
from        category c0_ 
inner join  camp c1_       ON c0_.campId = c1_.id
...
where       c1_.id = ?

to:

select      ...
from        category c0_ 
inner join  camp c1_       ON c0_.campId = c1_.id
...
where       c0_.id IN (
                SELECT c9_.id 
                FROM category c9_ 
                INNER JOIN camp c10_ ON c9_.campId = c10_.id 
                WHERE c10_.id = ?
            )

@pmattmann pmattmann added the deploy! Creates a feature branch deployment for this PR label Jan 18, 2025
@github-actions
Copy link

github-actions bot commented Jan 18, 2025

Feature branch deployment currently inactive.

If the PR is still open, you can add the deploy! label to this PR to trigger a feature branch deployment.

@pmattmann
Copy link
Member Author

pmattmann commented Jan 18, 2025

Measurement of Prod-DB:

Old: 1 - 4 Sek
SELECT
	...
FROM
	CATEGORY C0_
	INNER JOIN CAMP C1_ ON C0_.CAMPID = C1_.ID
	LEFT JOIN CATEGORY_CONTENTTYPE C8_ ON C0_.ID = C8_.CATEGORY_ID
	LEFT JOIN CONTENT_TYPE C2_ ON C2_.ID = C8_.CONTENTTYPE_ID
	INNER JOIN CONTENT_NODE C3_ ON C0_.ROOTCONTENTNODEID = C3_.ID
	AND C3_.STRATEGY IN ('columnlayout')
	LEFT JOIN CONTENT_NODE C4_ ON C3_.ROOTID = C4_.ID
	AND C4_.STRATEGY IN ('columnlayout')
	LEFT JOIN CONTENT_NODE C5_ ON C3_.PARENTID = C5_.ID
	AND C5_.STRATEGY IN ('contentnode', 'columnlayout', checklistnode', 'storyboard', 'responsivelayout', 'singletext', 'materialnode', 'multiselect')
	LEFT JOIN CONTENT_NODE C6_ ON C3_.ID = C6_.PARENTID
	AND C6_.STRATEGY IN ('contentnode', 'columnlayout', checklistnode', 'storyboard', 'responsivelayout', 'singletext', 'materialnode', 'multiselect')
	INNER JOIN CONTENT_TYPE C7_ ON C3_.CONTENTTYPEID = C7_.ID
WHERE
	C0_.ID IN (
		SELECT
			C9_.ID
		FROM
			CATEGORY C9_
			INNER JOIN CAMP C10_ ON C9_.CAMPID = C10_.ID
		WHERE
			C10_.ID = '882ef43cb000'
	)
	AND C0_.CAMPID IN (
		SELECT
			V11_.CAMPID AS SCLR_89
		FROM
			VIEW_USER_CAMPS V11_
		WHERE
			V11_.USERID = '8b3d14421000'
	)
ORDER BY
	C0_.CREATETIME DESC,
	C1_.ID ASC,
	C0_.SHORT ASC,
	C2_.NAME ASC;
New: ~80ms
SELECT
	...
FROM
	CATEGORY C0_
	INNER JOIN CAMP C1_ ON C0_.CAMPID = C1_.ID
	LEFT JOIN CATEGORY_CONTENTTYPE C8_ ON C0_.ID = C8_.CATEGORY_ID
	LEFT JOIN CONTENT_TYPE C2_ ON C2_.ID = C8_.CONTENTTYPE_ID
	INNER JOIN CONTENT_NODE C3_ ON C0_.ROOTCONTENTNODEID = C3_.ID
	AND C3_.STRATEGY IN ('columnlayout')
	LEFT JOIN CONTENT_NODE C4_ ON C3_.ROOTID = C4_.ID
	AND C4_.STRATEGY IN ('columnlayout')
	LEFT JOIN CONTENT_NODE C5_ ON C3_.PARENTID = C5_.ID
	AND C5_.STRATEGY IN ('contentnode', 'columnlayout', checklistnode', 'storyboard', 'responsivelayout', 'singletext', 'materialnode', 'multiselect')
	LEFT JOIN CONTENT_NODE C6_ ON C3_.ID = C6_.PARENTID
	AND C6_.STRATEGY IN ('contentnode', 'columnlayout', checklistnode', 'storyboard', 'responsivelayout', 'singletext', 'materialnode', 'multiselect')
	INNER JOIN CONTENT_TYPE C7_ ON C3_.CONTENTTYPEID = C7_.ID
WHERE
	C0_.CAMPID = '882ef43cb000'
	AND C0_.CAMPID IN (
		SELECT
			V11_.CAMPID AS SCLR_89
		FROM
			VIEW_USER_CAMPS V11_
		WHERE
			V11_.USERID = '8b3d14421000'
	)
ORDER BY
	C0_.CREATETIME DESC,
	C1_.ID ASC,
	C0_.SHORT ASC,
	C2_.NAME ASC;

@carlobeltrame
Copy link
Member

Maybe judging by the name it allows to filter by some eager loaded relation? E.g. /camps/1a2b3c4d/categories?filter[color]=ff0000 or /camps/1a2b3c4d/activities?filter[category.color]=ff0000 or something similar?

@pmattmann pmattmann added the Meeting Discuss Am nächsten Core-Meeting besprechen label Jan 19, 2025
@pmattmann pmattmann force-pushed the feature/category-endpoint-performance branch from 59a1b33 to 250bfa3 Compare January 23, 2025 06:03
@pmattmann
Copy link
Member Author

@BacLuc
Can you also measure this variant?
(analogue to #6756 (comment))

@BacLuc
Copy link
Contributor

BacLuc commented Feb 1, 2025

@BacLuc Can you also measure this variant? (analogue to #6756 (comment))

of course: BacLuc@b8c0f26

@manuelmeister
Copy link
Member

manuelmeister commented Feb 6, 2025

Core Meeting Decision

FilterEagerLoadingExtension is a bugfix for api-platform/core#944. We need to find a way to improve the current situation. e.g:

  • check if filter only targets root alias columns
  • could also fix many2one

@BacLuc BacLuc removed the Meeting Discuss Am nächsten Core-Meeting besprechen label Feb 6, 2025
@pmattmann pmattmann added this pull request to the merge queue Feb 6, 2025
Merged via the queue into ecamp:devel with commit 868be12 Feb 6, 2025
39 of 40 checks passed
@pmattmann pmattmann deleted the feature/category-endpoint-performance branch February 6, 2025 20:28
@carlobeltrame carlobeltrame mentioned this pull request Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy! Creates a feature branch deployment for this PR Performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants