Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Add Eager Loading support #15

Closed
wbrowar opened this issue Sep 25, 2018 · 4 comments
Closed

Add Eager Loading support #15

wbrowar opened this issue Sep 25, 2018 · 4 comments
Labels
enhancement New feature or request

Comments

@wbrowar
Copy link

wbrowar commented Sep 25, 2018

I've got a page with a map that shows 246 entries that use an Address field. This adds one query for each address field lookup so the page uses up a lot of memory and takes a while to load.

I am using Craft Blitz to cache the page, but when the cache is busted and when a visitor goes to this page the entire site goes down when a user loads this page until all of the data is loaded.

Can Eager Loaded support be added so these queries can be made along with the entries that contain the Address field?

For reference, the queries out of the Yii debug toolbar look like this:

Time Duration Type Duplicated Query
11:51:34.662 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='676') AND (fieldId='4')[+] Explain
11:51:34.663 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='677') AND (fieldId='4')[+] Explain
11:51:34.663 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='678') AND (fieldId='4')[+] Explain
11:51:34.664 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='679') AND (fieldId='4')[+] Explain
11:51:34.665 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='680') AND (fieldId='4')[+] Explain
11:51:34.666 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='681') AND (fieldId='4')[+] Explain
11:51:34.667 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='682') AND (fieldId='4')[+] Explain
11:51:34.668 0.2 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='683') AND (fieldId='4')[+] Explain
11:51:34.669 0.1 ms SELECT 1 SELECT * FROM craft_smartmap_addresses WHERE (elementId='684') AND (fieldId='4')

Unfortunately my client is putting pressure on me to come up with a solution and eager loading sounds like a good fix for this situation, but also for other times where we might need an Address field.

Thanks,
Will

@lindseydiloreto
Copy link
Contributor

Hi Will,

Hard to say what the solution is here... Ping me on Craft Slack and we can discuss it.

@lindseydiloreto
Copy link
Contributor

Ok, reporting back...

It looks like Craft itself only handles eager loading between related elements. But, it may be possible with some simple Yii code.

https://www.yiiframework.com/wiki/834/relational-query-lazy-loadnig-and-eager-loading-in-yii-2-0#eager-loading

I'm not prepared to go down that rabbit hole at this exact moment, so I'm mainly noting this for future reference. We'll leave this ticket open until I can implement it in a future version.

@lindseydiloreto lindseydiloreto added the enhancement New feature or request label Sep 26, 2018
@piotrpog
Copy link

@lindseydiloreto
Im in same sitiuation as wbrowar. So, i just wanted to signal my support for adding eager loading functionality to smartmap :)

@lindseydiloreto
Copy link
Contributor

This issue has been migrated to the Google Maps repo. To stay up-to-date, subscribe over there...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants