Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: simple sql optimize help/mlml
You helped me , /*+ INDEX_JOIN(wlog) */ WORKS!
pls see below,...
about 4 seconds
Mike
(ctcgag_at_hotmail.com) writes:
> ae299_at_FreeNet.Carleton.CA (Michel Lee) wrote:
>> Please help me speed up this query. >> when i run this query , it takes 46 secs. >> wlog table has many rows (> 30million). >> SQL> SELECT count(1) FROM wlog >> 2 WHERE >> 3 LOG_DATE > '14-JUN-04' and >> 4 user_id=6; >> COUNT(1) >> ---------- >> 696 >> Elapsed: 00:00:46.07
>> >> THIS IS the exec plan >> Execution Plan >> ---------------------------------------------------------- >> 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=5039 Card=1 Bytes=12) >> 1 0 SORT (AGGREGATE) >> 2 1 TABLE ACCESS (BY INDEX ROWID) OF 'WLOG' (Cost=5039 >> Card=1769 Bytes=21228) >> 3 2 INDEX (RANGE SCAN) OF 'USER_ID_IX' (NON-UNIQUE) (Cost=24 >> Card=10562)
>> also, i tried to analyze the 2 indexes , log_date_ix , user_id_ix and >> table wlog >> i would think that having indexes on each column will give a fast >> performance, but its not, >> ??
SELECT /*+ INDEX_JOIN(wlog) */ count(1) FROM wlog WHERE
LOG_DATE > to_date('14-JUN-04','DD-MON-RR') and user_id=6;
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=20709 Card=1 Bytes=12) 1 0 SORT (AGGREGATE)
2 1 VIEW OF 'index$_join$_001' (Cost=20709 Card=1769 Bytes=21228) 3 2 HASH JOIN 4 3 INDEX (RANGE SCAN) OF 'USER_ID_IX' (NON-UNIQUE) (Cost=759025 Card=1769 Bytes=21228) 5 3 INDEX (RANGE SCAN) OF 'LOG_DATE_IX' (NON-UNIQUE)(Cost=759025 Card=1769 Bytes=21228)
> Xho
>
> --
> -------------------- http://NewsReader.Com/ --------------------
> Usenet Newsgroup Service $9.95/Month 30GB
-- /-------------------------------------------------------------------/ / http://miccc.com / /-------------ae299_at_ncf.ca------------------------------------------/Received on Mon Jun 21 2004 - 08:48:35 CDT