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 special hasMany case where only one has many case will be selected. #363

Open
spl1nes opened this issue Feb 2, 2024 · 0 comments

Comments

@spl1nes
Copy link
Member

spl1nes commented Feb 2, 2024

If only one has many case is selected it shouldn't perform a child request but rather perform a join.

$tasks = TaskMapper::getAll()
            ->with('tags')
            ->with('tags/title')
            ->with('taskElements')
            ->where('title', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
            ->where('tags/title/language', $response->header->l11n->language)
            ->sort('createdAt', OrderType::DESC)
            ->sort('taskElements/createdAt', OrderType::ASC)
            ->limit(25)
            ->limit(1, 'taskElements')
            ->execute();

Careful, there is another bug relating limit on has many members.

There is also a variation of this discussed in the ReadMapper with localizations as example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant