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

Disable FilterEagerLoadingsExtension for better performance #6720

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

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
Copy link

github-actions bot commented Jan 18, 2025

Feature branch deployment ready!

Name Link
😎 Deployment https://pr6720.ecamp3.ch/
🔑 Login [email protected] / test
🕒 Last deployed at Thu Jan 23 2025 07:08:25 GMT+0100
🔨 Latest commit 250bfa380685ef847963111b181e53ad4e045fbc
🔍 Latest deploy log https://github.com/ecamp/ecamp3/actions/runs/12923261096/job/36040421428
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

@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
@BacLuc BacLuc added the api-performance-test! Run API Performance test 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 pmattmann deployed to feature-branch January 23, 2025 06:07 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-performance-test! Run API Performance test deploy! Creates a feature branch deployment for this PR Meeting Discuss Am nächsten Core-Meeting besprechen Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants