Jump to content

Ryan Marks

Approved members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Ryan Marks

  1. I'm trying to capture data from Revive by way of a MySQL query that will be consumed by a client-facing statistics dashboard. The data I'm interested in is Client name, Client ID (stored in Client Comments), Date, Total Impressions, Total Clicks, Affiliate name. I've written the following query, but it takes a while to respond: SELECT client.clientname AS `Client` , client.comments AS `Client ID` , DATE_FORMAT( CONVERT_TZ( STR_TO_DATE(stats.date_time, '%Y-%m-%d'), 'GMT', 'America/Chicago'), '%Y-%m-%d') AS `Date` , SUM( stats.`impressions` ) AS `Impressions` , SUM( stats.`clicks` ) AS `Clicks` , affiliate.name as 'Website' FROM `ox_clients` client LEFT JOIN `ox_campaigns` campaign USING (clientid) LEFT JOIN `ox_banners` banner USING (campaignid) LEFT JOIN `ox_data_summary_ad_hourly` stats ON banner.bannerid = stats.ad_id LEFT JOIN `ox_zones` zone ON stats.zone_id = zone.zoneid LEFT JOIN `ox_affiliates` affiliate USING (affiliateid) WHERE client.comments <> '' -- we only want clients with the comments field populated AND DATE_FORMAT( CONVERT_TZ( STR_TO_DATE(stats.date_time, '%Y-%m-%d'), 'GMT', 'America/Chicago'), '%Y-%m-%d') = DATE(NOW()) - INTERVAL 1 DAY GROUP BY client.clientid , affiliate.name , DATE_FORMAT( CONVERT_TZ( STR_TO_DATE(stats.date_time, '%Y-%m-%d %H:%i:%s'), 'GMT', 'America/Chicago'), '%Y-%m-%d') ORDER BY DATE_FORMAT( CONVERT_TZ( STR_TO_DATE(stats.date_time, '%Y-%m-%d %H:%i:%s'), 'GMT', 'America/Chicago'), '%Y-%m-%d') The above query took 48 seconds to run. I ran an explain which is below. Is there a query I can use that will help me get to the dimensions and metrics I've mentioned above?
×
×
  • Create New...