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

Models with belongsToMany relationships are slow #103

Open
jeremymlane opened this issue Oct 12, 2016 · 0 comments
Open

Models with belongsToMany relationships are slow #103

jeremymlane opened this issue Oct 12, 2016 · 0 comments

Comments

@jeremymlane
Copy link
Contributor

I have a model that has a belongsToMany relation and has 200 related models in that relation that is VERY slow to load. Takes several seconds to load when the SQL queries themselves are taking only ms to run.

I ran the xdebug profiler on it and it looks like DataLinksHelper::relationshipsLinksSelf is very very slow. When I comment this line:

https://github.com/nilportugues/php-json-api/blob/master/src/Helpers/DataLinksHelper.php#L170

the whole request takes less than a second with no changes to the relations, etc. Was unsure if I should post this issue on this repo or here: https://github.com/nilportugues/php-json-api/.

Anyway, not sure if there's anything that can be done to speed it up, but I thought I'd check. Here's a screenshot of the xdebug profile. Each call to the function takes 431ms and it's called for every one of the related models.

screen shot 2016-10-12 at 11 39 36 am

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

No branches or pull requests

1 participant