Interesting question, especially these phrases in it that caught my attention:
- ... writing queries using the PDO layer ...
- ... an efficient query ...
Moreover, the title of this question (= "Use Views or Write Raw Query?") sounds to me that you might be interested in learning about other options available, different from using the views module. If that's the case, then the Forena module is another option to consider. It comes with quite some community documentation. And "Write Raw Query" is exactly one of the things you would use Forena for (i.e. what in forena is called 'data blocks').
Forena is built of the idea of using SQL to get data out of a database (which can be the Drupal database or an external one such as My SQL, Oracle, MS SQL, ...) and use XHTML and CSS to format it into web reports. There are quite some reasons for considering Forena, which also explains how "Forena complements the views module" (suggested in some other answers here also), i.e.:
- "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."
- "What does it take to create reports / charts with the typical Business Intelligence tools? Where would I start in case such reports are to be shown on a Drupal site ... and the actual data may either come from any of Drupal's own tables, or in a PDO-style external database, or some XML or CSV file?" ... Trying to answer these questions leads to more questions such as "How far can you get (and what would it take to get there) with the views module (not even talking about how to secure the access to such data)?
Visit the Forena HowTos page for some links (near the bottom) to some live demo / showcase links.
Refer to the example in my answer to https://drupal.stackexchange.com/questions/152166/fetching-drupal-articles-tags-image-directly-from-database/154746#154746 to get an idea of what it is like to use Forena, such as the SQL query and the source of the "custom report", which looks like so:
<title>My custom report title</title>
<frx:category>Articles related Reports</frx:category>
Consider the above sample as an alternative to what in one of the answers is mentioned, i.e.: "Now if you try and do the above mentioned points in a custom module I am pretty sure you will run over a 500 lines of code to implement most of the features.Also don't forget the custom code which needs to be maintained.". I do agree with that, in cases where Forena is not being considered (eg because not many people seem to know about it?).
Similar thoughts about what I read in another answer, i.e.: "Views brings many additional features to the table as well. For example, theming, caching, access control and integration with hundreds of contributed modules through an easy to swallow UI.". In case of Forena these additional features are available also, except that there are not 100s of such modules (though there are integrations with heavily used modules like feeds, bean, views, date, etc). In case of Forena these few modules will get you pretty far. After all, don't we always try to have as few as possible contributed module enabled? So I'd hope I don't need too much of all those 100 to just enhance the views based approach. And how many sites don't have at least views and date already enabled, probably also bean more and more.
What I don't seem to read anywhere here in the question, or any answers, are these Forena supported features that might make sense to consider also:
- How far do you get with views if the data are coming from an external database?
- What about aggregation types of operations, like the features of the views_calc module? Disclosure: I recently became a legacy maintainer of it's D6 version.
Refer to Forena's community docu mentioned above for details about how Forena does also address those issues (and how it complements views ...). If appropriate, I'd be happy to further expand this answer to explain Forena AbitMORE.
Disclosure: I'm a co-maintainer (not owner ...) of this module,
I hope this does not violate the site's policy on self-promotion.