This is what I am doing:
- Running query that Grabs all albums for an owner
- Looping through the 1. query, and run another query to grab cover_pic from photo where pid= cover_pid and show it.
- In the same loop through the 1. query, I am now also running another query that selects photos limit 5 and show them.
This is: 1 + 1 + 5 = 7 queries Per album, and there's 33 albums = 231 Queries, which takes TIME to load the site, and destroys the user experience!
I have after debugging found out it's not the 1. query that are taking its time to load, but the 2. and 3. (2. runs 33 queries and 3. runs 165 queries!)
How can I in any way reduce this?
I guess I need to rethink the structure, but I cant see any better solution to load the 2. and 3.
I have thought about cookies, sessions to save so next time it is faster, but I think that the first load will the user leave because of the loading time, and therefore next time doesnt matter..
Please use the Graph API Field Expansion tool to achieve this.
eg - graph.facebook.com/[USER_ID]?fields=name,albums.fields(cover_photo,photos.limit(5))
You can visually construct the query using the Graph Explorer