Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Performance Improvement when querying tags on model especially for models with lots of records and with tags #206

Merged
merged 1 commit into from
Mar 28, 2022

Conversation

juresyahya
Copy link
Contributor

Reference Issues/PRs

None

Issues

When using laravel-tagging with models that has tags but lots of records, there is a performance issues when using withAnyTags to retrieve particular models with specific tags. The 'where In' clause for the query will also show duplicate TagIds in the resulting eloquent queries.

What does this implement/fix? Explain your changes.

In the codes where it pluck('taggable_id'), I've included laravel collection method unique() to remove this duplicate TagIds. This reduce the number of tags included in the 'Where In' clause of the model and increase performance by roughly 40%.

Any other comments?

No

@rtconner rtconner merged commit 4645bf6 into rtconner:laravel-8 Mar 28, 2022
@rtconner
Copy link
Owner

Love it, thank you for sharing this with the rest of us

@rtconner
Copy link
Owner

Release 4.1.3

@juresyahya juresyahya deleted the perf_improv branch March 28, 2022 05:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants