Sobes.tech
Senior

Dato un'interrogazione SQL scritta da un analista. Identifica le inefficienze nell'interrogazione e suggerisci come evitarle. L'interrogazione unisce due tabelle: - tabella dei fatti 'events' con chiave 'event_id' - tabella di riferimento della fonte di traffico con chiave 'referer_str' Entrambe le tabelle contengono miliardi di record. select * from (select distinct e.event_id, e.user_id, e.category_id, e.location_id, s.source_name, s.medium_name, s.campaign_name, row_number() over(partition by e.event_id, e.user_id, e.category_id, e.location_id, s.source_name, s.medium_name, s.campaign_name) as rnk from events e left join traffic_source s on e.referer_str = s.referer_str where e.event_date = current_date() - 1 group by 1,2,3,4,5,6,7) t where rnk = 1