Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> Enhancing Query Join to speed up Query


Copy link to this message
-
Re: Enhancing Query Join to speed up Query
Hi

I would actually do it like this…so that the set on the left of JOIN becomes smaller

SELECT a.item_id, a.create_dt
FROM
     ( SELECT
                    item_id, create_dt
      FROM
                    A
      WHERE
                   item_id = 'I001'
       AND
                  category_name = 'C001'
      )  a
JOIN
         b
ON
        a.item_id = b.item_id
;
From: Naga Vijay <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>
Reply-To: "[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>" <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>
Date: Wednesday, June 12, 2013 9:17 PM
To: "[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>" <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>
Subject: Enhancing Query Join to speed up Query

Hi,

Which of the two query options is better?

SELECT a.item_id, a.create_dt
FROM   a JOIN b
ON     (a.item_id = b.item_id)
WHERE  a.item_id = 'I001'
AND    a.category_name = 'C001';

- or -

SELECT a.item_id, a.create_dt
FROM   a JOIN b
ON     (a.item_id = b.item_id AND a.item_id = 'I001')
WHERE  a.category_name = 'C001';

Thanks
Naga

CONFIDENTIALITY NOTICE
=====================This email message and any attachments are for the exclusive use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message along with any attachments, from your computer system. If you are the intended recipient, please be advised that the content of this message is subject to access, review and disclosure by the sender's Email System Administrator.