Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Sql Tuning help

RE: Sql Tuning help

From: Toepke, Kevin M <ktoepke_at_cms.cendant.com>
Date: Wed, 07 Feb 2001 10:29:45 -0800
Message-ID: <F001.002ADAA7.20010207070708@fatcity.com>

Try one of these variations  

SELECT TO_CHAR(NVL(SUM(sb.bet_amount),0)) FROM sb_bets sb

     ,customers c
WHERE sb.processed_date >= ADD_MONTHS(TO_DATE('07011999 000000','MMDDYYYY HH24MISS'),19-1)
AND sb.processed_date < add_months(TO_DATE('07011999 000000','MMDDYYYY HH24MISS'),19)
AND sb.customer_id = c.customer_id
AND c.licensee_id = 6130;  

Or   

SELECT TO_CHAR(NVL(SUM(sb.bet_amount),0)) FROM sb_bets sb
WHERE sb.processed_date >= ADD_MONTHS(TO_DATE('07011999 000000','MMDDYYYY HH24MISS'),19-1)
AND sb.processed_date < add_months(TO_DATE('07011999 000000','MMDDYYYY HH24MISS'),19)
AND EXISTS (SELECT 1

              FROM   customers  c
              WHERE  c.customer_id = sb.customer_id
              AND    c.licensee_id = 6130);
 

Make sure the following indexes exist:

    sb_bets (processed_date)
    customers (customer_id, licensee_id)  

Kevin

-----Original Message-----
Sent: Wednesday, February 07, 2001 8:31 AM To: Multiple recipients of list ORACLE-L

I have been having some problems with this statement SELECT to_char(NVL(SUM(bet_amount),0))
FROM sb_bets
WHERE processed_DATE >= add_months(TO_DATE('07011999 000000','MMDDYYYY HH24MISS'),19-1) AND processed_DATE < add_months(TO_DATE('07011999 000000','MMDDYYYY HH24MISS'),19) AND customer_id in (select customer_id from customers
where customers.customer_id=sb_bets.customer_id and LICENSEE_ID=6130)

Both tables are full access no indexes used. There is an index on sb_bets.processed_date and customers.customer_id is a primary key and customers.licensee_id has an index also. Of course this query may just pull too many customer ids to bother with an index. But that is not too bad only 200000 records in customers but over 12 million in sb_bets. Is there a better way of writing this query? I have tried hints but still nothing changed. Any ideas would be greatly appreciated.  

Please email me for any further info thanks.       

Matt Southcott
DBA
Starnetsystems
(268) 480 1734
   

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Toepke, Kevin M
  INET: ktoepke_at_cms.cendant.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Wed Feb 07 2001 - 12:29:45 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US