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: query help.

Re: query help.

From: cw <cw_at_netlimit.com>
Date: Thu, 22 Aug 2002 10:44:50 -0800
Message-ID: <F001.004BD32A.20020822104450@fatcity.com>


Thanks Kavi, People like you made this world more beautiful. I will give it a try.      



Original Message
Date: Thu, 22 Aug 2002 10:15:27 -0800

>Hi
>
>!. 'union's in general does take time and may not help improve your
>performance
> ( if you can find an alternative at this stage to replace that to
achieve
>the same
> query results - that would be great)
>2. You could run explain plan on this query t - get the query plan
> ( and check if there are lot full table scans which you think are
>expensive - try to
> avoid that by including appropriate index hint or by adding new
indexes
>)
>3 . Since you have lots of aggregate functions like (sum, decode, floor...
etc
>) and
> GROUP BY ====> this will be "SORT " intensive query - make sure all
the
>sorts
> are happening on the memory and not on the disk
> ( you could check that with tkprof statistics - as well )
>4. If any of the above needs to be expanded let me know (I can point to
some
>documentation
> which explains that or elabrate it to you , if you have metalink - you
>could search on
> that too : how to run get explain plan etc )
>
>Thanks,
>Kavi
>
>cw wrote:
>
>> I am a new oracle pl/sql developer. This is a very expensive query
and
>> it takes eight hours to produce a report. I just need some
validation
>> from guru's.
>> ----------------------------------------------
>> Original Message
>> Date: Thu, 22 Aug 2002 07:48:36 -0800
>>
>> >Hello,
>> >
>> >Did I miss portion of this email ?
>> >what help is needed for this query ? (tuning, explanation ....???)
>> >
>> >Thanks,
>> >Kavi
>> >
>> >cw wrote:
>> >
>> >> Hey list Guru, Can anyone help me with this query? Many thanks,
>> >>
>> >> SELECT
>> >> A.COUNTY_CODE,
>> >> C.COUNTY_NAME,
>> >> lpad(B.PRECINCT,4,' '),
>> >> count(*),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> A.DOB)-(18*12))/(1*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> A.DOB)-(19*12))/(11*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> A.DOB)-(30*12))/(10*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> A.DOB)-(40*12))/(10*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> A.DOB)-(50*12))/(10*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> A.DOB)-(60*12))/(5*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> A.DOB)-(65*12))/(10*99)),1,0)),
>> >> sum(decode(A.DOB, NULL, 1, 0))
>> >> FROM ONLINE_VOTERS A, ADDRESS_INDEX B, COUNTIES C
>> >> WHERE A.COUNTY_CODE = B.COUNTY_CODE
>> >> AND A.ADDRESS_ID = B.ADDRESS_ID
>> >> AND A.COUNTY_CODE = C.COUNTY_CODE
>> >> AND A.STATUS IN ('V','S')
>> >> GROUP BY A.COUNTY_CODE, C.COUNTY_NAME, lpad(B.PRECINCT,4,' ')
>> >> UNION ALL
>> >> SELECT
>> >> D.COUNTY_CODE,
>> >> C2.COUNTY_NAME,
>> >> lpad(D.PRECINCT,4,' '),
>> >> count(*),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> D.DOB)-(18*12))/(1*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> D.DOB)-(19*12))/(11*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> D.DOB)-(30*12))/(10*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> D.DOB)-(40*12))/(10*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> D.DOB)-(50*12))/(10*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> D.DOB)-(60*12))/(5*12)),1,0)),
>> >> sum(DECODE(0,floor((months_between(sysdate,
>> >> D.DOB)-(65*12))/(10*99)),1,0)),
>> >> sum(decode(D.DOB, NULL, 1, 0))
>> >> FROM OFFLINE_VOTERS D, COUNTIES C2
>> >> WHERE D.COUNTY_CODE = C2.COUNTY_CODE
>> >> AND D.STATUS IN ('V','S')
>> >> GROUP BY D.COUNTY_CODE, C2.COUNTY_NAME, lpad(D.PRECINCT,4,' ');
>> >>
>> >> _____________________________________________
>> >> Free email with personality! Over 200 domains!
>> >> http://www.MyOwnEmail.com
>> >>
>> >> --
>> >> Please see the official ORACLE-L FAQ: http://www.orafaq.com
>> >> --
>> >> Author: cw
>> >> INET: cw_at_netlimit.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).
>> >
>> >
>>
>> _____________________________________________
>> Free email with personality! Over 200 domains!
>> http://www.MyOwnEmail.com
>>
>> --
>> Please see the official ORACLE-L FAQ: http://www.orafaq.com
>> --
>> Author: cw
>> INET: cw_at_netlimit.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).
>
>



Free email with personality! Over 200 domains! http://www.MyOwnEmail.com
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: cw
  INET: cw_at_netlimit.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 Thu Aug 22 2002 - 13:44:50 CDT

Original text of this message

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