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?

CommentFileSizeAuthor
#1 815940-views_get_view-comments.patch860 bytesdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
860 bytes
. The thing is that if it is not a default view it builds up a data array of all the known default views.

This 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.

  elseif (!empty($view) && !empty($default_view)) {
    $view->type = t('Overridden');
  }

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.

TCRobbert’s picture

Status: Needs review » Closed (works as designed)

Thanks 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.

dawehner’s picture

Component: Views Data » Documentation
Status: Closed (works as designed) » Needs review

Wth are you doing with the issue? :( Even a documentation patch might be fine.

esmerel’s picture

Status: Needs review » Reviewed & tested by the community

looks ok to me

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Code comment committed.

As an aside, the view export module makes it relatively easy to export a bunch of views to code.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.