Im currently working on optimizing a rather big drupal website (100+ modules). One of the things ive been trying to limit is the amount of queries that are being run for each page and optimize them where possible.
I noticed that views seems to check for cached views data for each view displayed on a page and going through this function: function &views_get_default_view($view_name)
Even though the views for certain pages do not make use of the default views. The thing is that if it is not a default view it builds up a data array of all the known default views. Unfortunately in my case with the amount of modules enabled this results in a 23 extra queries being run to fill that array.
I did find out that the array is static so for any other views used on a page it wont run those queries anymore. None the less 23 extra queries is a bit useless if the data isnt even used.
I was wondering if something can be done about this?
Comment | File | Size | Author |
---|---|---|---|
#1 | 815940-views_get_view-comments.patch | 860 bytes | dawehner |
Comments
Comment #1
dawehnerThis should be only the case if the default view is not in the cache. If it's not in the cache, the views get's loaded and should then be stored in the cache. I will look at the issue.
Here is one approach. In general, you should export the view to you code, because then you have the view in your revision control system.
So i tryed to patch it, but its perfect how it is currently.
As you see, we have to detect whether a view is overriden, or just added.
So as solution i suggest you to export your views to code.
The more i think about it, the more i have to think about it.
This patch just makes comments to understand the function better.
Comment #2
TCRobbert CreditAttribution: TCRobbert commentedThanks for the reply.
I figured there wouldnt be much room to really adjust it. When I went through the code I pretty much came to the same conclusion as you did. I was just hoping I was overlooking something.
To export the views to code at this point would be a hell of a job. And I managed to get it optimized quite well. So ill leave it as it is for now.
Again thanks for your time.
Comment #3
dawehnerWth are you doing with the issue? :( Even a documentation patch might be fine.
Comment #4
esmerel CreditAttribution: esmerel commentedlooks ok to me
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedCode comment committed.
As an aside, the view export module makes it relatively easy to export a bunch of views to code.