So, because of numerous complications that I'll save you all from having to read here, I am forced to use views_embed_view alot to create complex lists of content. A quick example would be, having a view that shows a bunch of nodes, and embedding within that view a grid of all the users who have flagged that node, and below that view, yet another embedded view showing the total count of all of the users that have flagged that node. So for a regular view that shows 6 paginated nodes, each one of those 6 has 2 specific views embedded in it. So that block actually is calling 13 views in total.
My question is this: Since there doesn't seem to be a way to perform these tasks w/o embedding views, what's the cost going to be to system resources? If I do alot of this, is it going to cause my server's cpu usage to spike through the clouds? I'm just looking for some guidance/warnings while going forward.
Thanks!
Comments
Comment #1
dawehnerEvery additional creating of a view object, every additional query needs resources.
Its incredible to predict how this affect your site performance, but sure it will not be the fastests. I suggest to use caching to reduce the overhead as much as possible.
Comment #2
merlinofchaos commentedEmbedding views within views is going to be a lot harder on your database than it will on your CPU, most likely, because you get an exponential increase in the number of queries based upon the number of records for each view. Let's say you have view 1, which runs view 2 for every record, which in turn runs view 3 for every record. If view 1 produced 10 records, and view 2 produces an average of 10 records per run, that means view 3 is going to end up being run 10 x 10 == 100 times. That can absolutely cripple your database if view 3 is not an absolutely cheap query to run; and even if it IS that's still pretty expensive.
Caching can help somewhat, of course, but it won't entirely mitigate this cost.
Comment #3
rc2020 commentedThanks,
This is helpful information. I'm reopening just to see if I can get a point clarified. I'm honestly a little worried about my method to implement this solution if it's going to be so database intensive. I have an example at http://www.lifeundersun.com. You'll see a panels block in the right-hand side that says 'places to go.' You'll see, for example, 'Killington, Vermont. That is a view of a node type with picture, taxonomy, some themed flag links, etc, etc - but you'll see a grid of some user pictures with a count of the view. Those are embedded views of users who have referenced that node.
Is there another way to deliver this functionality without embedding views within views that you could possibly think of? If not, is there a less resource intensive method than views_embed_view()? I'm just worried about what happens when I hit 50K users....
Comment #4
dawehnerSadly ou removed the users.
views_embed_view does not really something else then the rest of views. I guess the most performant would be if you figure out your own sql and build a field_handler with pre_render. But this is far from being simple.