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: Re: cardinality in query plans?

Re: Re: cardinality in query plans?

From: <ryan.gaffuri_at_cox.net>
Date: Mon, 15 Mar 2004 12:05:16 -0500
Message-Id: <20040315170516.BWCD5813.lakemtao04.cox.net@smtp.east.cox.net>


response in line
>
> From: "Jonathan Lewis" <jonathan_at_jlcomp.demon.co.uk>
> Date: 2004/03/15 Mon AM 11:07:10 EST
> To: <oracle-l_at_freelists.org>
> Subject: Re: Re: cardinality in query plans?
>
>
> There are a couple of articles of mine on
> www.dbazine.com/oracle.shtml which may
> explain why Oracle chooses the tablescan
> for "billy%" Note, though, that based on the
> "billy" value, Oracle is reporting the right
> cardinality, and doing the right thing. Oracle
> is doing the slow path when it gets the right
> answer for the cardinality.
>
> Before you move to hinting, have you examined
> system statistics. If you can calibrate the system
> so that it has a realistic single-block read time compared
> to multiblock read time, the paths may correct themselves
> automatically. You also need to get the apparent CPU
> speed into the system, so that Oracle can check the
> CPU cost of scanning all those rows.

system stats may not be an option. We will not have access to the production system, yet have to guarantee performance. so when do i know to run the gather_system_stats?
>
> However - before you get to that - are you sure that
> the sample query is correct. Oracle defaults to using
> a RANGE scan on TAB1_PK according to the plan,
> but there appear to be no columns it could be using
> to avoid a FULL scan.
>

ahhhh... I totally botched this. I have the alias backwards. All columns are present in the index. Sorry about this.

select /*+ ordered index(a TAB2_IND) */ COL3, COL4, COL5

                   from TAB2 a, TAB1 b
                  WHERE b.col1 = a.col1
                    AND b.col2 = a.col2
                    AND b.col3 = a.col3
                    and col6 =  'hello'
                    and a.searchCol like upper('billy%')
                  order by a.hh_nm, a.hh_id, a.acct_no 


correct plan

 CASE 2 Now with hints or bind variables:

Execution Plan



0 SELECT STATEMENT Optimizer=CHOOSE (Cost=346 Card=1 Bytes=140) 1 0 VIEW (Cost=346 Card=1 Bytes=140)
2 1 COUNT (STOPKEY)
3 2 VIEW (Cost=346 Card=1 Bytes=127)
4 3 WINDOW (SORT) (Cost=346 Card=1 Bytes=89)
5 4     WINDOW (SORT) (Cost=346 Card=1 Bytes=89)
6 5      HASH JOIN (Cost=344 Card=1 Bytes=89)
7 6       INDEX (RANGE SCAN) OF 'TAB2_IND'(UNIQUE) (Cost=11 Card=2250 
Bytes=36000)
8 6        TABLE ACCESS (BY INDEX ROWID) OF 'TAB' (Cost=337 Card=43539 
Bytes=3178347)
9 8        INDEX (RANGE SCAN) OF 'TAB1_PK' (NON-UNIQUE) (Cost=44 Card=1)


> Is it possible that there is some other predicate on
> TAB1 that is causing the problem (it seems to be
> returning only 2250 rows out of 16M in the default
> plan) or are the statistics on the TAB1 index totally
> misleading ?

I just generated the statistics. This is an oltp query and there should not be many records returned.

>
> (I have no comment to make on TAB2 and the other
> table at the moment).
>
> Regards
>
> Jonathan Lewis
> http://www.jlcomp.demon.co.uk
>
> The Co-operative Oracle Users' FAQ
> http://www.jlcomp.demon.co.uk/faq/ind_faq.html
>
> April 2004 Iceland
> June 2004 UK - Optimising Oracle Seminar
>
>
> ----- Original Message -----
> From: <ryan.gaffuri_at_cox.net>
> To: <oracle-l_at_freelists.org>
> Sent: Monday, March 15, 2004 3:36 PM
> Subject: Re: Re: cardinality in query plans?
>
>
> : yes billy in this case uses a large fraction of the results. 262,000
> records out of 870,000. I really would prefer not to hint. I do not have
> production data yet, so big and small in production may not be the same.
> however, we are currently in acceptance testing so when the client sees the
> query we must not have a problem.
> :
> : is there anyway to provide oracle with better information? The odd thing
> was that in the past on a different data set, I had to remove bind variables
> to make this same query work. This is troubling.
> :
> : I'll attempt to analyze the 10053 trace and I have a TAR open.
> :
> : Why would Oracle cost a full table scan lower than an index search even in
> spite of the large number of records? I can clearly tell with runstats_pkg
> that the index scan is better.
> :
> : Here is another oddity. If I use hard coded values. I then ONLY hint the
> index, oracle uses the index, but the incorrect join order. This is
> happening in a join between TAB2 and another table also.
> :
> : I am fearful of hints since I cannot predict what the data will look like
> in production. I may not see the production data at all due to security
> reasons(not government, its private sector), yet I have to guarantee
> performance. Per our SLA this has to support 30,000 concurrent users. Now
> trimming off 9,000 LIOs on a frequently used query is very important to
> scaling this application.
> :
>
>
> ----------------------------------------------------------------
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> ----------------------------------------------------------------
> To unsubscribe send email to: oracle-l-request_at_freelists.org
> put 'unsubscribe' in the subject line.
> --
> Archives are at http://www.freelists.org/archives/oracle-l/
> FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
> -----------------------------------------------------------------
>



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Mon Mar 15 2004 - 11:01:48 CST

Original text of this message

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