Link to home
Start Free TrialLog in
Avatar of pksplus
pksplusFlag for Mexico

asked on

Does views heavly affect performance on Drupal?

I am inmersed in a discussion to decide whether to use Views on a Drupal site or not, since Views is one of the most used modules I am biased to use it, however I have inherited a Drupal site where the former developers avoid using views and craft their "own optimized queries" arguing that Views hits performance a lot. While I might agree with the statement that a optimized query is better than a View I feel that there are other ways to scale a site using without loosing Views functionality.
What I would like to know from you guys is your opinion about how hard is performance affected by Views and the possible solutions, techniques, tutorials.
Please tell me if you consider to avoid Views as a reasonable option?
SOLUTION
Avatar of Thomas4019
Thomas4019
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kent Olsen
Hi Pks,

Views are generally "atomic operations".  That is, a view returns a result set (via a derived table) that is then passed through the filter clause of your Select statement.  If the view returns a large result set you'll likely get better performance by writing your query to access the database tables directly.

Consider these two views:

1.  CREATE VIEW v1 AS select * from mytable
2.  CREATE VIEW v2 AS select * from mytable WHERE {condition-1}


Now let's use them.


  SELECT * from v1
  SELECT * from v2

Either of the queries above will give you the same performance as if the query were against the table (mytable).


  SELECT * from v1 where {condition-2}
  SELECT * from v2 where {condition-3}

These are a little trickier.  The first of these will also perform as if the query were against the base table.  

However, the last one will not.  The RDBMS will apply the filter in the view and generate a result set.  The filter in the SELECT statement will be applied to the result set.  It is handled separately from the filter in the view.  If the view returns a lot of rows you may see a performance issue.  This especially frustrating if the filter in the query COULD have used an index if the condition were checked in the view.

Views are great things.  But they aren't always the correct solution.


Kent
Don't forget it's a good idea to cache your views where practical - if you have numerous views this can really help!
Avatar of pksplus

ASKER

Ok I'm assuming that your answer apply to both cases Views as from a Database perspective and the Drupal Views Module, which is the topic of this question. Part of my confusion always happen when talking about big or small queries, and big and small sites, would you please tell me what do you define as a big site and a big query (how many elements), of course I understand that this answer has to do with the hardware, but  lets consider a threshold of one single server. In other words:
 
How many load do you consider a Drupal site will handle before you have to use more complex  or distributed techniques to scale? and
How much would the same will increase its performance its performance using custom  outputs instead of using the Views Module?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial