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

Optimize tag permissions #126

Merged
merged 13 commits into from
May 4, 2021
Merged

Optimize tag permissions #126

merged 13 commits into from
May 4, 2021

Conversation

askvortsov1
Copy link
Member

@askvortsov1 askvortsov1 commented Apr 24, 2021

Currently, to check the tags where users have permissions, we:

  • Pull in all tags
  • Make a big array of all tags
  • Send it back to the DB for a whereIn.

This is quite slow. Instead of doing this, this PR creates a subquery for all tags where a user has a permission, then feeds that subquery to whereIns. Combined with #87, this makes a setup with:

  • 50 top level primary tags
  • 500 primary subtags distributed among the 50
  • 3000 secondary tags

have negligible effects on initial page load.

Most of this PR is tests, don't be scared of the line changes!

askvortsov1 and others added 7 commits April 23, 2021 18:03
The new implementation generates a subquery of IDs instead of sending big arrays of data to/from the database. This massively speeds up performance.
Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

I still need to look into the new query, but here are a few initial comments

.vscode/launch.json Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
src/Tag.php Show resolved Hide resolved
@askvortsov1 askvortsov1 requested a review from SychO9 April 29, 2021 22:38
Copy link
Contributor

@tankerkiller125 tankerkiller125 left a comment

Choose a reason for hiding this comment

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

Testing locally everything seems to be working OK

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

Query looks good as far as I can tell.

src/Tag.php Outdated Show resolved Hide resolved
src/Tag.php Show resolved Hide resolved
@askvortsov1 askvortsov1 merged commit fe996c3 into master May 4, 2021
@luceos luceos deleted the as/optimize-tag-permissions branch May 5, 2021 06:50
askvortsov1 added a commit that referenced this pull request Mar 11, 2022
The new implementation generates a subquery of IDs instead of sending big arrays of data to/from the database. This massively speeds up performance.
askvortsov1 added a commit that referenced this pull request May 10, 2022
The new implementation generates a subquery of IDs instead of sending big arrays of data to/from the database. This massively speeds up performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants