Skip to content

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
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.

2 participants