Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2011
    Posts
    34

    Unanswered: SQL Tunning Help

    Hey Guys, I was wondering if someone could help me with a performance question.

    I am wondering if breaking a query into a nested queries is better than just putting all joins together?

    here is a fake basic example just to illustrate what I mean... I am using partition pruning on dates etc. my tables are large (approx 1 million records per day)


    Query 1)
    select
    *
    from customer c
    join transactions t on c.accountnumber = t.accountnumber and t.purchase_date >= sysdate - 365
    where c.state_code = 'CA'
    go

    or

    Query 2)
    select
    *
    from
    (
    select
    *
    from customer c
    where c.state_code = 'CA'
    )x
    join transactions t on x.accountnumber = t.accountnumber

    where t.purchase_date >= sysdate - 1
    go


    pretty much I am asking is it better to select the players that I need first and then get the details or does it even matter?

    Thanks for the help guys
    - Using Oracle 11g with Toad v12

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Did you compare the "explain plans"?
    What is the difference?
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Dec 2007
    Posts
    253
    What database are you using for this? Your siggy implies that you're using db2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •