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

lighten select for single circle #863

Merged
merged 2 commits into from
Dec 16, 2021

Conversation

ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Dec 10, 2021

Lighten slightly a frequently used request:

  • removing useless DISTINCTROW
  • INNER instead of LEFT
  • removing useless ORDER

Old version:

SELECT DISTINCTROW single . unique_id , single . name , single . display_name , single . sanitized_name , single . source , single . description , single . settings , single . config , single . contact_addressbook , single . contact_groupname , single . creation FROM oc_circles_circle single LEFT JOIN oc_circles_member single_member ON single_member . circle_id = single . unique_id WHERE ( ( single_member . user_id = ? ) AND ( single_member . user_type = ? ) AND ( single_member . instance = ? ) AND ( single_member . level >= ? ) ) AND ( ( single . config & ? ) > ? ) GROUP BY single . creation , single . unique_id , single . name , single . display_name , single . sanitized_name , single . source , single . description , single . settings , single . config , single . contact_addressbook , single . contact_groupname ORDER BY single . creation ASC

New version:

SELECT single.unique_id, single.name, single.display_name, single.sanitized_name, single.source, single.description, single.settings, single.config, single.contact_addressbook, single.contact_groupname, single.creation FROM oc_circles_circle single INNER JOIN oc_circles_member single_member ON single_member.circle_id = single.unique_id WHERE ((single_member.user_id = ?) AND (single_member.user_type = ?) AND (single_member.instance = ?) AND (single_member.level >= ?)) AND (single.config IN ('1', '8193')) GROUP BY single.creation, single.unique_id, single.name, single.display_name, single.sanitized_name, single.source, single.description, single.settings, single.config, single.contact_addressbook, single.contact_groupname

@ArtificialOwl ArtificialOwl force-pushed the enh/noid/lighten-single-circle-select branch 2 times, most recently from 92f4d04 to e23d964 Compare December 10, 2021 12:23
@ArtificialOwl ArtificialOwl force-pushed the enh/noid/lighten-single-circle-select branch 2 times, most recently from 913178c to 334c40c Compare December 12, 2021 12:26
@skjnldsv skjnldsv requested review from a team, juliusknorr, skjnldsv, CarlSchwan, nickvergessen and ChristophWurst and removed request for a team December 13, 2021 07:49
@skjnldsv skjnldsv added the high label Dec 13, 2021
@ChristophWurst ChristophWurst removed their request for review December 13, 2021 07:55
@ArtificialOwl ArtificialOwl force-pushed the enh/noid/lighten-single-circle-select branch from 334c40c to b8ecd30 Compare December 13, 2021 11:38
@ArtificialOwl
Copy link
Member Author

indexes looks good, if the request is still too heavy, the next step will be to generate a 'cache' table that store the singleId of the Single Circle based on current sessionId or userId

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl ArtificialOwl force-pushed the enh/noid/lighten-single-circle-select branch from b8ecd30 to 50eddb3 Compare December 14, 2021 16:12
@ArtificialOwl
Copy link
Member Author

Using redis to cache the result of getSingleCircle() for 15 minutes

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Copy link
Member

@CarlSchwan CarlSchwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't really comment on the sql query itself since I'm unfamiliar with the circle and how the data is stored but the caching part of this PR looks correct to me

@ArtificialOwl
Copy link
Member Author

/backport to stable23

@ArtificialOwl
Copy link
Member Author

/backport to stable22

@ArtificialOwl ArtificialOwl merged commit 5ac5fe9 into master Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants