Racing Minis at Zandvoort
Photo: Copyright © 2019 Eelke Blok


Finding number of Drupal-nodes created per hour in a single query

For a customer I've been running an import of old content into a Drupal installation and I got the feeling that the process seemed to run slower and slower. We say "meten is weten" in Dutch ("measuring is knowing"), so I wondered if it was possible to write a single SQL query to find out how many nodes were created per hour since the start of the import. This is the query I came up with:

SELECT FLOOR((node.changed - 1304604369) / 3600) AS hour, COUNT(nid) FROM node WHERE node.changed >= 1304604369 GROUP BY hour;

Video: Getting Started with Apache Solr

None of this Drupalified "there's a module for that" stuff. This is hard core, direct talking to Solr