Benefit of running custom query over views


Another module to consider for situations where views "might need some help" is Forena (disclosure: I'm a co-maintainer of it). Here is a quote from one of its community docu pages, i.e. Reasons for considering Forena:

"Why not use views instead of forena?" ... The answer is generally something along the lines of "Most forena users love views, views is great! If you want to report against external data though, or you want to do aggregation or analytics, Forena is much more suited to address these requirements."

And since this question is about blocks also, you may want to take advantage of the Forena integration with the Bean module. Here is a quote about that module, its project page:

Think of a Bean as a method to provide new types (compared to node this would be a content type) which then provides an add content interface to create as many blocks as you require (see screenshot below). The bean content can then be placed around the site just like any other block.

You may also want to look at my answers to these somehow related, I think, questions:

  • How to retrieve data directly from a Drupal database.
  • Use Views or Write Raw Query?

Not really. you should stick to using Views; it will provide you more benefits. To name a couple:

  • Less custom code to maintain; it's one of the mostly heavily used modules and will be part of D8 core. There's much less worries of security holes, bugs, etc.
  • The versatility of the Views features: caching, multiple view displays, filtering, a UI to change all this, etc.

I'd say the only exception to this would be the instances where your query is going to be hit very often, in which case you'd might be able to squeeze more performance out of an optimized SQL query.

For your needs, a block of 10 latest nodes, views will do everything you need it to, not be a burden on performance, and will take much less time to complete than creating & maintaining possibly bug ridden custom code.

Tags: Database

Similar questions

Drupal watchdog database table flooded with same message over and over?
I've: And still, the same error message is being written to Watchdog. I execute: "delete from watchdog" and IMMEDIATELY after I check in the watchdog table, the same error is there. Not that it would help, but here's the error: AND So, my questions are:
My Drupal 7 batch processing code is repeating the final iteration of the batch process over and over. Can someone help me fix it?
I'm trying to move data from an old database to a new one. My code doesn't currently write anything (which is fine), but the reading repeats over and over on the last record even though $context['finished'] is set to 1. Any idea what I'm doing wrong?
Running a custom query alongside Drupal Registration Query
Good afternoon all. I would like to implement a custom query during the registration process of my registration. I've taken a look around online and can't find the information anywhere, so if anybody knows where the registration query is ran, so that I can add another query to it that would be awesome. Thanks in advance. EDIT The Query that runs al...
Advantages of utilizing Entity Field query over views?
I've been reading a little about entity field queries. What are the advantages of using entity field queries (EFQ) over views? What are the largest pain points/disadvantages of using EFQ ?
Cron stopped running; logs say: "Attempting to re-run cron while it is already running."
What are the steps to troubleshoot and resolve this issue as per title? When I try to run manually, I get a page immediately, and the error message "Attempting to re-run cron while it is already running."
Running a django project in a subdirectory of a site already running Drupal
This problem has been bugging me for the last week or so and now I am coming up on a deadline. I have a site on a Media Temple DV server that is running Drupal in the webroot ( I am adding a django site and I would like it to be located at the url I have build the project (in a directory not in the webroot)...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.