在Netezza中查询性能

时间:2015-02-12 11:18:45

标签: performance netezza

我不知道这是在Netezza中提问查询性能问题的正确论坛吗?如果没有,请告诉我在哪里发布这些类型的问题?

以下哪个查询会更有效?

--QUERY1:

UPDATE
S_F_PROMOTION_HISTORY
SET
  SENT_IND = SENT.SENT_IND,
  SEND_DT = SENT.SEND_DT
FROM
  (
    SELECT PROMO_HIST_ID, 1 AS SENT_IND, MIN(RESPONSE_DT) SEND_DT
    FROM
    S_STG_SMS_FEEDBACK
    WHERE
    RESPONSE_ACTIVITY_TYPE_ID = 50
    GROUP BY
    PROMO_HIST_ID
 ) SENT
WHERE
S_F_PROMOTION_HISTORY.PROMO_HIST_ID = SENT.PROMO_HIST_ID;



--Query2:

CREATE TEMP TABLE SENT_TABLE AS
SELECT
  PROMO_HIST_ID, 1 AS SENT_IND, MIN(RESPONSE_DT) SEND_DT
FROM
  S_STG_SMS_FEEDBACK
WHERE
  RESPONSE_ACTIVITY_TYPE_ID = 50
  GROUP BY PROMO_HIST_ID DISTRIBUTE ON PROMO_HIST_ID;

UPDATE
  S_F_PROMOTION_HISTORY
SET
  SENT_IND = SENT.SENT_IND,
  SEND_DT = SENT.SEND_DT
FROM 
  SENT_TABLE SENT 
WHERE 
  S_F_PROMOTION_HISTORY.PROMO_HIST_ID=SENT.PROMO_HIST_ID;

或者它们是等价的,因为Temp表也将驻留在内存而不是磁盘上,因此没有区别,因为正在进行连接的表的相同分配键?

在第二个查询中,我将查询分成两部分,并在连接键上分发内部表,然后更新基表。

0 个答案:

没有答案