嗨我想知道在左联盟中增加额外条件是否会提高性能。 示例代码如下。 我只需知道某些优惠的价格数据,但需要所有优惠数据。 只是想知道是否值得采用额外的连接条件来加速性能?
SELECT
*
FROM
OFFERS
LEFT JOIN PRICE ON (
PRICE.PH_SUBS_LINK_SK = ACTSUBS.PH_SUBS_LINK_SK and
PRICE.PRICE_END_DT= '09-09-9999' and
OFFERS.PERCENT_VALUE >0 and
OFFERS.VALUE_OR_PERCENT = 'PERCENT' and
OFFERS.PRODUCT_OFFER_TYPE = 'RC' and
OFFERS.OFFER_STATUS_CODE in ('ACT','PTM')
)
答案 0 :(得分:0)
我建议更改以上代码:
SELECT
*
FROM
OFFERS
LEFT JOIN PRICE ON
PRICE.PH_SUBS_LINK_SK = ACTSUBS.PH_SUBS_LINK_SK
WHERE PRICE.PRICE_END_DT= '09-09-9999' and
OFFERS.PERCENT_VALUE >0 and
OFFERS.VALUE_OR_PERCENT = 'PERCENT' and
OFFERS.PRODUCT_OFFER_TYPE = 'RC' and
OFFERS.OFFER_STATUS_CODE in ('ACT','PTM')
要提高性能,请在where语句中使用的字段创建索引。