By dado on
My site like many is becoming increasingly dependent on CCK and views. Good news- these ar both glorious modules. My trouble- slow views. 1 of my views_build_view queries takes 5 seconds consistently. Drupal's page caching only works for anonymous users, so I am effectively punishing users who register for account with slow response time
OK, yes it is a 5 table query. But curious- has anyone identified a way to cache pages or queries for logged in users, or to cache views queries?
Comments
best solution: remove views fields
OK, so I still think some mechanism or module to selectively cache views_build_view queries would be nifty. But here is the best solution for slow multitable views queries, when using CCK nodes. It basically makes use of CCK's node caching, and it made my execution time of views_build_view drop from 4800ms to 13ms!
(1) install the devel module and enable tracking query execution times. Pay attention to the time for views queries, especially views_build_view
(2) export/import your slow view, to make a copy of it. Give it new name.
(3) In your new slow view, remove all fields for your view except the node title.
(4) create a custom views theme function through which to render your view, as per here
http://drupal.org/node/42597
(5) In your loop rendering your view, load the CCK node. You can then render any/all fields that the node possesses very cheaply.
Example code: SLOWER
Example code: FASTER
dado
another solution: use teaser list
you can also do this to optimize your complex multitable views
(1) In your new slow view, select view as teaser list
(2) remove all fields for your view except the node title.
(3) if this is a view of CCK nodes: because CCK teasers are problematic at this writing, you might need to implement Nick Lewis' or other workaround to get proper teasers.
http://www.nicklewis.org/node/844
dado
dado, I know its been 2+
dado, I know its been 2+ years, but what are the changes I need to make to this example above to make it work for Drupal 5. I have an issue with views execution timeL http://drupal.org/node/284416
100824.83 ms views_build_view
Thanks, I am just going to try it out now. My CCK views taxonomy query is killing my site...
My Drupal sites: