我尝试了两种不同的方法来执行此查询,但是我收到的表太大了,无法连接第一个,而第二个查询执行期间资源超出了...
这些查询:
SELECT COUNT(DISTINCT(s_pageview_id)) as total
FROM impressions.tbl_impressions_201405
WHERE i_browser IN (1)
AND fk_i_id_tbl_vertical IN (1)
AND i_section IN (1)
AND s_ads_list != ''
AND b_is_human = true
AND DATE(dt_date) = '2014-05-28'
AND s_pageview_id NOT IN (
SELECT s_pageview_id
FROM impressions.tbl_impressions_201405
WHERE i_section IN (26,27,83,96)
AND i_browser IN (1)
AND fk_i_id_tbl_vertical IN (1)
AND DATE(dt_date) = '2014-05-28'
AND s_ads_list != ''
AND b_is_human = true
)
第二次查询:
SELECT COUNT(*) AS total
FROM impressions.tbl_impressions_201405 as impressions_1
LEFT OUTER JOIN EACH impressions.tbl_impressions_201405 as impressions_2
ON impressions_1.s_pageview_id = impressions_2.s_pageview_id
WHERE impressions_2.i_browser IN (1)
AND impressions_2.fk_i_id_tbl_vertical IN (1)
AND impressions_2.i_section IN (1)
AND impressions_2.b_is_human = true
AND DATE(impressions_2.dt_date) = '2014-05-28'
AND impressions_1.i_section IN (26,27,83,96)
你知道其他任何尝试方法吗?!
非常感谢你......
答案 0 :(得分:0)
您的问题严重缺乏元数据。你的桌子有多大,第一个的连接在哪里等等。但是:
1)尝试JOIN EACH
。使用this visualisation as a guide,您可以更加具体地使用联接
2)尝试保存表并允许大的结果。