Ryan Marks Posted July 5, 2018 Report Posted July 5, 2018 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? Quote
andrewatfornax Posted July 6, 2018 Report Posted July 6, 2018 Hi Ryan, I haven't actually run your query, so, just to clarify - is the issue that your query isn't returning the data you want (and you need help getting the right info), or is the issue that it takes a while to return (and you need help making it faster)? Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.