I have a node type product and a node type review. The review has a node reference field pointing to the node type product. Using the Node Reference URL module a user can click a link on the product page and create a review of that product. The View that renders a list of the reviews is show below the product node on the node type product view page.

I tried to add comments to the View by configuring in Views UI Format -> show -> content -> full content -> show comments. However, this did not render any of the comments. Instead I created another View of type comments using the Entity Views Attach module. So each content type review now has a field that loads a View of comments using its nid.

This works great. Still there is a now few extra queries run for each review of each product which I think is a case of the n+1 select problem.

I enabled the Devel performance logger to look at how much of a hit this causes to performance. Without rendering the extra comments and attaching them to each rendered node of type review the number of queries is 165 and the query time is 95MS (my computer is super old) with the comments rendered for each node of type review the number of queries is 189 and the query time is 111MS.

(edit) I had to hack Views to test if using the content with comments was faster than adding a different View as a field to the Review content type. Oddly the number of queries was 188 with a query time of 138MS so the slightly more convoluted method was faster.

Will I be shooting my self in the foot with a bad performance bottleneck with this configuration?

If you are having a difficult time visualizing this, it is just like Stack Exchange. With a node type question that has comments. There is node type answer that is rendered in View attached to the node type question view page. Each answer can have comments too. Same thing.

  • would you mind sharing how you build the views with the Entity Views Attach module? I tried it recently but couldn't get it to work. thx
    – uwe
    Jun 23, 2011 at 1:38
  • I think that requires asking an new question.
    – Adam S
    Jun 23, 2011 at 2:29
  • makes sense ;-) drupal.stackexchange.com/questions/5732/…
    – uwe
    Jun 23, 2011 at 17:33

1 Answer 1


You are creating a n+1 select problem, but you would do that if you created a list of full nodes since extra queries will happen on every full node display.

This isn't necessarily problem though, as you probably don't want to display 100 or 1000 nodes this way, but instead use a pager. When using a pager, n will never be more than your pager count which could be something like 10 or 20. 10 or 20 queries is not ideal but hardly a problem either unless you need to run a very high performance site, but if that were the case, you probably wouldn't use views anyways.

Views has some cache options which could be used to optimize, and reduce all of the queries to a single query on the cache instead. That is an easy of increasing performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.