Rule-Based Optimizer doesn4t use the index
Does anybody know why the rule-based optimizer doesn4t use the index of all columns in the where clause?
I have a select that use the hint RULE to force the optimizer to work in rule mode and also one index to all columns used in the where clause. Analyzing the execution plan (EXPLAIN PLAN) I observed the optimizer accesses all tables, but one, using the index. There4s one table (the first of the execution plan) that is accessed using a Full Table Scan (FTS).
I've rebuilt the index for this table, but the execution plan doesn4t change.
Any suggestions?
Thanks in advance.
Eliane.
Hi. Oracle may not use an index if it finds that a full table scan is quicker/more efficient. Try the hint /*+ INDEX (table index) */ and compare the query performance with that of the one without this hint. (As you know, if you force Rule-based approach, the COST column in EXPLAIN PLAN output will not be populated. You may have to use trace/tkprof.)
Similar Messages
-
Rule based optimizer vs Cost based optimizer - 9i
Is Rule based optimizer not used any more or can be used depending on the application etc.
I think Rule based optimizer still has some advantages. Please give your input if you think otherwise.
ThxI think Rule based optimizer still has some
advantages. Please give your input if you think
otherwise.You are absolutely correct. There are a few advantages to RBO.
RBO is better for any application that meets the following criteria:
- designed for Oracle version 7;
- has not been updated since Oracle 7;
- was hand tuned in Oracle 7;
- will not be upgraded to Oracle Database 10g (where RBO is obsolete);
- will not use Bitmap Indexes, Materialized Views, Query Rewrite, or vitrtually anything that was introduced in Oracle8 and beyond.
CBO, while not perfect, will allow new features to be used. And it is improving with every release. -
How to avoid full Table scan when using Rule based optimizer (Oracle817)
1. We have a Oracle 8.1.7 DB, and the optimizer_mode is set to "RULE"
2. There are three indexes on table cm_contract_supply, which is a large table having 28732830 Rows, and average row length 149 Bytes
COLUMN_NAME INDEX_NAME
PROGRESS_RECID XAK11CM_CONTRACT_SUPPLY
COMPANY_CODE XIE1CM_CONTRACT_SUPPLY
CONTRACT_NUMBER XIE1CM_CONTRACT_SUPPLY
COUNTRY_CODE XIE1CM_CONTRACT_SUPPLY
SUPPLY_TYPE_CODE XIE1CM_CONTRACT_SUPPLY
VERSION_NUMBER XIE1CM_CONTRACT_SUPPLY
CAMPAIGN_CODE XIF1290CM_CONTRACT_SUPPLY
COMPANY_CODE XIF1290CM_CONTRACT_SUPPLY
COUNTRY_CODE XIF1290CM_CONTRACT_SUPPLY
SUPPLIER_BP_ID XIF801CONTRACT_SUPPLY
COMMISSION_LETTER_CODE XIF803CONTRACT_SUPPLY
COMPANY_CODE XIF803CONTRACT_SUPPLY
COUNTRY_CODE XIF803CONTRACT_SUPPLY
COMPANY_CODE XPKCM_CONTRACT_SUPPLY
CONTRACT_NUMBER XPKCM_CONTRACT_SUPPLY
COUNTRY_CODE XPKCM_CONTRACT_SUPPLY
SUPPLY_SEQUENCE_NUMBER XPKCM_CONTRACT_SUPPLY
VERSION_NUMBER XPKCM_CONTRACT_SUPPLY
3. We are querying the table for a particular contract_number and version_number. We want to avoid full table scan.
SELECT /*+ INDEX(XAK11CM_CONTRACT_SUPPLY) */
rowid, pms.cm_contract_supply.*
FROM pms.cm_contract_supply
WHERE
contract_number = '0000000000131710'
AND version_number = 3;
However despite of giving hint, query results are fetched after full table scan.
Execution Plan
0 SELECT STATEMENT Optimizer=RULE (Cost=1182 Card=1 Bytes=742)
1 0 TABLE ACCESS (FULL) OF 'CM_CONTRACT_SUPPLY' (Cost=1182 Card=1 Bytes=742)
4. I have tried giving
SELECT /*+ FIRST_ROWS + INDEX(XAK11CM_CONTRACT_SUPPLY) */
rowid, pms.cm_contract_supply.*
FROM pms.cm_contract_supply
WHERE
contract_number = '0000000000131710'
AND version_number = 3;
and
SELECT /*+ CHOOSE + INDEX(XAK11CM_CONTRACT_SUPPLY) */
rowid, pms.cm_contract_supply.*
FROM pms.cm_contract_supply
WHERE
contract_number = '0000000000131710'
AND version_number = 3;
But it does not work.
Is there some way without changing optimizer mode and without creating an additional index, we can use the index instead of full table scan?David,
Here is my test on a Oracle 10g database.
SQL> create table mytable as select * from all_tables;
Table created.
SQL> set autot traceonly
SQL> alter session set optimizer_mode = choose;
Session altered.
SQL> select count(*) from mytable;
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'MYTABLE' (TABLE)
Statistics
1 recursive calls
0 db block gets
29 consistent gets
0 physical reads
0 redo size
223 bytes sent via SQL*Net to client
276 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> analyze table mytable compute statistics;
Table analyzed.
SQL> select count(*) from mytable
2 ;
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=11 Card=1)
1 0 SORT (AGGREGATE)
2 1 TABLE ACCESS (FULL) OF 'MYTABLE' (TABLE) (Cost=11 Card=1
788)
Statistics
1 recursive calls
0 db block gets
29 consistent gets
0 physical reads
0 redo size
222 bytes sent via SQL*Net to client
276 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> disconnect
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options -
Hi all,
On one of the production server we are using RULE BASED OPTIMIZER(Its application requirement).
I have to tune this database as users are complaining about the performance.
Any tips how can I tune for a RULE BASED optimizer database.
Does the tuning statergy will remain same as like seeing execution plan for missing index,instance paramets
execpt you cant generate stats.
Regards
UmairHi!
There are one thing about RBO, YOU must check all long-running queryis for it's
execution plans, try find better plans and after force RBO to using it.
You can use different hints for changing eceution plans. But for tuning RBO's database you must soent a very big time, YOU must be a CBO ;) -
Improving performace for a Rule Based Optimizer DB
Hi,
I am looking for information on improving the current performance of an ancient 35GB Oracle 7.3.4 using RULE based optimizer mode. It is using 160 MB SGA and the physical memory on the system is 512MB RAM.
As of now, all the major tasks which take time, are run after peak hours so that the 130 user sessions are not affected significantly.
But recently am told some procedures take too long to execute ( procedure has to do with truncating tables and re-populating data into it ) and I do see 54% of the pie chart for WAITS are for "sequential reads" followed by "scattered reads" of 36%. There are a couple of large tables of around 4GB in this DB.
Autotrace doesn't help me much in terms of getting an explain plan of slow queries since COST option doesnt show up and am trying to find ways of improving the performance of DB in general.
Apart from the "redo log space requests" which I run into frequently (which btw is something I am trying to resolve ..thanks to some of you) I dont see much info on exactly how to proceed.
Is there any info that I can look towards in terms of improving performance on this rule based optimizer DB ? Or is identifying the top sql's in terms of buffer gets the only way to tune ?
Thank you for any suggestions provided.Thanks Hemant.
This is for a 15 minute internal under moderate load early this morning.
Statistic Total Per Transact Per Logon Per Second
CR blocks created 275 .95 5.19 .29
Current blocks converted fo 10 .03 .19 .01
DBWR buffers scanned 74600 258.13 1407.55 78.44
DBWR free buffers found 74251 256.92 1400.96 78.08
DBWR lru scans 607 2.1 11.45 .64
DBWR make free requests 607 2.1 11.45 .64
DBWR summed scan depth 74600 258.13 1407.55 78.44
DBWR timeouts 273 .94 5.15 .29
OS Integral shared text siz 1362952204 4716097.59 25716079.32 1433177.92
OS Integral unshared data s 308759380 1068371.56 5825648.68 324668.12
OS Involuntary context swit 310493 1074.37 5858.36 326.49
OS Maximum resident set siz 339968 1176.36 6414.49 357.48
OS Page faults 3434 11.88 64.79 3.61
OS Page reclaims 6272 21.7 118.34 6.6
OS System time used 19157 66.29 361.45 20.14
OS User time used 195036 674.87 3679.92 205.09
OS Voluntary context switch 21586 74.69 407.28 22.7
SQL*Net roundtrips to/from 16250 56.23 306.6 17.09
SQL*Net roundtrips to/from 424 1.47 8 .45
background timeouts 646 2.24 12.19 .68
bytes received via SQL*Net 814224 2817.38 15362.72 856.18
bytes received via SQL*Net 24470 84.67 461.7 25.73
bytes sent via SQL*Net to c 832836 2881.79 15713.89 875.75
bytes sent via SQL*Net to d 42713 147.8 805.91 44.91
calls to get snapshot scn: 17103 59.18 322.7 17.98
calls to kcmgas 381 1.32 7.19 .4
calls to kcmgcs 228 .79 4.3 .24
calls to kcmgrs 20845 72.13 393.3 21.92
cleanouts and rollbacks - c 86 .3 1.62 .09
cleanouts only - consistent 40 .14 .75 .04
cluster key scan block gets 1051 3.64 19.83 1.11
cluster key scans 376 1.3 7.09 .4
commit cleanout failures: c 18 .06 .34 .02
commit cleanout number succ 2406 8.33 45.4 2.53
consistent changes 588 2.03 11.09 .62
consistent gets 929408 3215.94 17536 977.3
cursor authentications 1746 6.04 32.94 1.84
data blocks consistent read 588 2.03 11.09 .62
db block changes 20613 71.33 388.92 21.68
db block gets 40646 140.64 766.91 42.74
deferred (CURRENT) block cl 668 2.31 12.6 .7
dirty buffers inspected 3 .01 .06 0
enqueue conversions 424 1.47 8 .45
enqueue releases 1981 6.85 37.38 2.08
enqueue requests 1977 6.84 37.3 2.08
execute count 20691 71.6 390.4 21.76
free buffer inspected 2264 7.83 42.72 2.38
free buffer requested 490899 1698.61 9262.25 516.19
immediate (CR) block cleano 126 .44 2.38 .13
immediate (CURRENT) block c 658 2.28 12.42 .69
logons cumulative 53 .18 1 .06
logons current 1 0 .02 0
messages received 963 3.33 18.17 1.01
messages sent 963 3.33 18.17 1.01
no work - consistent read g 905734 3134.03 17089.32 952.4
opened cursors cumulative 2701 9.35 50.96 2.84
opened cursors current 147 .51 2.77 .15
parse count 2733 9.46 51.57 2.87
physical reads 490258 1696.39 9250.15 515.52
physical writes 2265 7.84 42.74 2.38
recursive calls 37296 129.05 703.7 39.22
redo blocks written 5222 18.07 98.53 5.49
redo entries 10575 36.59 199.53 11.12
redo size 2498156 8644.14 47135.02 2626.87
redo small copies 10575 36.59 199.53 11.12
redo synch writes 238 .82 4.49 .25
redo wastage 104974 363.23 1980.64 110.38
redo writes 422 1.46 7.96 .44
rollback changes - undo rec 1 0 .02 0
rollbacks only - consistent 200 .69 3.77 .21
session logical reads 969453 3354.51 18291.57 1019.4
session pga memory 35597936 123176.25 671659.17 37432.11
session pga memory max 35579576 123112.72 671312.75 37412.8
session uga memory 2729196 9443.58 51494.26 2869.82
session uga memory max 20580712 71213.54 388315.32 21641.13
sorts (memory) 1091 3.78 20.58 1.15
sorts (rows) 12249 42.38 231.11 12.88
table fetch by rowid 57246 198.08 1080.11 60.2
table fetch continued row 111 .38 2.09 .12
table scan blocks gotten 763421 2641.6 14404.17 802.76
table scan rows gotten 13740187 47543.9 259248.81 14448.15
table scans (long tables) 902 3.12 17.02 .95
table scans (short tables) 4614 15.97 87.06 4.85
total number commit cleanou 2489 8.61 46.96 2.62
transaction rollbacks 1 0 .02 0
user calls 15266 52.82 288.04 16.05
user commits 289 1 5.45 .3
user rollbacks 23 .08 .43 .02
write requests 331 1.15 6.25 .35Wait Events :
Event Name Count Total Time Avg Time
SQL*Net break/reset to client 7 0 0
SQL*Net message from client 16383 0 0
SQL*Net message from dblink 424 0 0
SQL*Net message to client 16380 0 0
SQL*Net message to dblink 424 0 0
SQL*Net more data from client 1 0 0
SQL*Net more data to client 24 0 0
buffer busy waits 169 0 0
control file sequential read 55 0 0
db file scattered read 74788 0 0
db file sequential read 176241 0 0
latch free 6134 0 0
log file sync 225 0 0
rdbms ipc message 10 0 0
write complete waits 4 0 0I did enable the timed_stats for the session but dont know why the times are 0's. Since I cant bounce the instance until weekend, cant enable the parameter in init.ora as well. -
Why isn't my query using the index?
I have a query that inserts values for engines in a grid; it uses a static date table to determine the day in week, or
week in year (depending on different standards, the DBA can configure this table to their business's likings). I have
two indexes on this table:
create table d_date (
date_key number(5) not null,
sql_calendar_date timestamp(3) null,
year_id number(5) null,
month_id number(3) null,
day_id number(3) null,
year_end_biz_date timestamp(3) null,
qtr_end_biz_date timestamp(3) null,
month_end_biz_date timestamp(3) null,
week_end_biz_date timestamp(3) null,
quarter_id number(3) null,
week_id number(3) null,
day_in_year number(5) null,
day_in_month number(3) null,
day_in_week number(3) null,
month_name char(3) null,
day_in_week_name char(3) null,
month_type_code char(1) null,
week_type_code char(1) null,
date_type_code char(1) null,
weekend_flag char(1) null,
holiday_flag char(1) null,
from_datetime timestamp(3) null,
to_datetime timestamp(3) null,
current_flag char(1) null,
constraint d_date_pkey primary key (date_key)
) tablespace dim;
create index d_date_dy on d_date(year_id, day_in_year) tablespace_dim_idx;
create index d_date_ww on d_date(year_id, week_id) tablespace_dim_idx;Now, when I run a query to insert the week id into a table based on two values, the year_key and day_in_year_key,
it should use the d_date_dy index correct?
Here is what the query looks like:
INSERT INTO F_ENGINE (YEAR_KEY,MONTH_KEY,WEEK_IN_YEAR_KEY,DAY_IN_YEAR_KEY,DAY_IN_MONTH_KEY,HOUR_IN_DAY_KEY, Q_HOUR_IN_DAY_KEY,
GRID_KEY,ENGINE_KEY,TIME_STAMP,ENGINE_CPU_UTIL,ENGINE_CPU_GRID_UTIL,MEMORY_TOTAL_BYTE, MEMORY_FREE_BYTE,DISK_FREE_MEGABYTE,
PROCESS_COUNT,ENGINE_ID,GRID_ID,GRID_NAME,BATCH_ID,RECORD_VIEWABLE_F)
SELECT EXTRACT(YEAR FROM START_DATETIME),EXTRACT(MONTH FROM START_DATETIME), DD.WEEK_ID,
TO_NUMBER(TO_CHAR(START_DATETIME, 'DDD')), EXTRACT(DAY FROM START_DATETIME),EXTRACT(HOUR FROM START_DATETIME),
FLOOR(EXTRACT(MINUTE FROM START_DATETIME)/15)*15,DG.GRID_KEY,DE.ENGINE_KEY, START_DATETIME,CPU_UTIL,DS_CPU,MEMORY,
FREE_MEMORY,FREE_DISK,PROCESSES,ID,PE.GRID,DG.GRID_NAME,:B1 ,1
FROM P_ENGINE PE, D_GRID DG, D_ENGINE DE, D_DATE DD
WHERE PE.GRID = DG.GRID_ID AND DG.CURRENT_FLAG = 'Y' AND PE.ID = DE.ENGINE_ID AND DE.GRID_KEY = DG.GRID_KEY AND
DE.CURRENT_FLAG = 'Y' AND PE.BATCH_ID = :B1 AND DD.YEAR_ID = EXTRACT(YEAR FROM START_DATETIME) AND
DD.DAY_IN_YEAR = TO_NUMBER(TO_CHAR(START_DATETIME,'DDD'))
ORDER BY EXTRACT(YEAR FROM START_DATETIME),EXTRACT(MONTH FROM START_DATETIME),
EXTRACT(DAY FROM START_DATETIME),EXTRACT(HOUR FROM START_DATETIME),FLOOR(EXTRACT(MINUTE FROM START_DATETIME)/15)*15,
DG.GRID_KEY,DE.ENGINE_KEY
Here is the explain plan:
Operation Object Object Type Order Rows Size (KB) Cost Time (sec) CPU Cost I/O Cost
INSERT STATEMENT
SORT ORDER BY
HASH JOIN
HASH JOIN
HASH JOIN
TABLE ACCESS FULL D_GRID TABLE 1 2 0.316 3 1 36887 3
TABLE ACCESS FULL D_ENGINE TABLE 2 10 0.410 3 1 42607 3
PARTITION LIST SINGLE 5 1434 344.496 9 1 2176890 9
TABLE ACCESS FULL P_ENGINE TABLE 4 1434 344.496 9 1 2176890 9
TABLE ACCESS FULL D_DATE TABLE 7 7445 283.550 19 1 3274515 18Now it is obviously not using the index for the d_date table since it is doing a full table access.
Does this have something to do with the fact that I am using extract(), to_number(), to_char() functions in my WHERE clause that it is not allowing the use of the index?
Any help would be greatly appreciated. Thanks.
-TimIt's difficult to tell just from this. For one thing, you didn't post your query using the forum format tags, so it's hard to read and you didn't post your Oracle version.
In the query, you don't always prefix columns with the table alias. That makes it impossible for us (and maintainers of this code) to know at a glance which table a column is in.
It's possible that performing functions on a column will disable the index. Do your other tables have indexes? Do you have updated statistics on all the tables?
The main reason the optimizer will not use an index is because it thinks it cheaper not to. -
hi,
my database is 10.2.0.1...by default optimizer_mode=ALL_ROWS..
for some sessions..i need rule based optimizer...
so can i use
alter session set optimizer_mode=rule;
will it effect that session only or entire database....
and following also.i want to make them at session level...
ALTER SESSION SET "_HASH_JOIN_ENABLED" = FALSE;
ALTER SESSION SET "_OPTIMIZER_SORTMERGE_JOIN_ENABLED" = FALSE ;
ALTER SESSION SET "_OPTIMIZER_JOIN_SEL_SANITY_CHECK" = TRUE;
will those effect only session or entire database...please suggest< CBO outperforms RBO ALWAYS! > I disagree - mildlyWhen I tune SQL, the first thing I try is a RULE hint, and in very simple databases, the RBO still does a good job.
Of course, you should not use RULE hints in production (That's Oracle job).
When Oracle eBusiness suite migrated to the CBO, they placed gobs of RULE hints into their own SQL!!
Anyway, always adjust your CBO stats to replicate an RBO execution plan . . . .
specifically CAST() conversions from collections and pipelined functions.Interesting. Hsve you tried dynamic sampling for that?
Hope this helps. . .
Don Burleson
Oracle Press author
Author of “Oracle Tuning: The Definitive Reference”
http://www.dba-oracle.com/bp/s_oracle_tuning_book.htm -
Hi,
Rule Based Optimization is a deprecated feature in Oracle 10g.We are in the process of migrating from Oracle 9i to 10g.I have never heard of this Rule based Optimization earlier.I have googled for the same.But, got confused with the results.
Can anybody shed some light on the below things...
Is this Optimization done by Oracle or as a developer do we need to take care of the rules while writing SQL statements?
There is another thing called Cost Based Optimization...
Who will instruct the Oracle whether to use Rule Based Optimization or cost Based Optimization?
Thanks & Regards,
user569598Hope the following explanation would be helpful.
Whenever a statement is fired, Oracle should goes through the following stages:
Parse -> Execute -> Fetch (fetch only for select statement).
During Parse, Oracle first evaluates, Syntatic checking (SELECT, FROM, WHERE, ORDER BY ,GROUP and etc) and then Semantic Checking (columns names, table name, user permission on the objects and etc). Once these two stages passes, then, it has to decided whether to do soft parse or hard parse. If similar cursor(statement) doesn't exits in the shared pool, Oracle goes for Hard parse where Optimizer comes in picture for generating query plan.
Oracle has to decide either RBO or CBO. It also depends on the OPTIMIZER_MODE parameter value. If RULE hint is used, RBO will be used, if there are no statistics for those tables involved in the query, Oracle decides RBO, (condition applies). If statistics are available, or dynamic samplying is defined then Oracle use CBO to prepare the Optimal execution plan.
RBO is simply relies on set of rules where CBO relies on statistical information.
Jaffar -
Why is this query not using the index?
check out this query:-
SELECT CUST_PO_NUMBER, HEADER_ID, ORDER_TYPE, PO_DATE
FROM TABLE1
WHERE STATUS = 'N'
and here's the explain plan:-
1
2 -------------------------------------------------------------------------------------
3 | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
4 -------------------------------------------------------------------------------------
5 | 0 | SELECT STATEMENT | | 2735K| 140M| 81036 (2)|
6 |* 1 | TABLE ACCESS FULL| TABLE1 | 2735K| 140M| 81036 (2)|
7 -------------------------------------------------------------------------------------
8
9 Predicate Information (identified by operation id):
10 ---------------------------------------------------
11
12 1 - filter("STATUS"='N')
There is already an index on this column, as is shown below:-
INDEX_NAME INDEX_TYPE UNIQUENESS TABLE_NAME COLUMN_NAME COLUMN_POSITION
1 TABLE1_IDX2 NORMAL NONUNIQUE TABLE1 STATUS 1
2 TABLE1_IDX NORMAL NONUNIQUE TABLE1 HEADER_ID 1
So why is this query not using the index on the 'STATUS' Column?
I've already tried using optimizer hints and regathering the stats on the table, but the execution plan still remains the same, i.e. it still uses a FTS.
I have tried this command also:-
exec dbms_stats.gather_table_stats('GECS','GEPS_CS_SALES_ORDER_HEADER',method_opt=>'for all indexed columns size auto',cascade=>true,degree=>4);
inspite of this, the query is still using a full table scan.
The table has around 55 Lakh records, across 60 columns. And because of the FTS, the query is taking a long time to execute. How do i make it use the index?
Please help.
Edited by: user10047779 on Mar 16, 2010 6:55 AMIf the cardinality is really as skewed as that, you may want to look at putting a histogram on the column (sounds like it would be in order, and that you don't have one).
create table skewed_a_lot
as
select
case when mod(level, 1000) = 0 then 'N' else 'Y' end as Flag,
level as col1
from dual connect by level <= 1000000;
create index skewed_a_lot_i01 on skewed_a_lot (flag);
exec dbms_stats.gather_table_stats(user, 'SKEWED_A_LOT', cascade => true, method_opt => 'for all indexed columns size auto');Is an example. -
Why is Oracle not using the index??
Hi,
I have a table called 'arc_errors' which has an index on 'member_number' as follows:- Create/Recreate indexes
create index DWO.DW_ARC_CERRORS_MNO on DWO.DW_ARC_CERRORS (MEMBER_NUMBER);
But surpisingly, when I execute the following query, it does not use the index.
SELECT member_number,
COUNT(*) error_count
FROM arc_errors a
WHERE member_number = 68534152 AND
( tx_type = 'SDIC' AND
error_number IN (4, 7, 12, 13, 15, 17, 18, 705) )
OR
( tx_type = 'AUTH' AND
error_number IN (100, 104, 107, 111, 116) )
OR
( tx_type = 'BHO' AND
error_number IN (708,710) )
OR
( tx_type = 'XLGN' AND
( error_number BETWEEN 102 AND 105 OR
error_number BETWEEN 107 AND 120 OR
error_number BETWEEN 300 AND 304 ) )
OR
( tx_type = 'None' AND
( error_number IN (20, 112) OR
error_number BETWEEN 402 AND 421 ) )
OR
( tx_type = 'HYBR' AND
error_number IN (303, 304) )
GROUP BY member_number;
This is what 'explain plan' tell me
SELECT STATEMENT, GOAL = RULE 237907 502923 15087690
SORT GROUP BY 237907 502923 15087690
PARTITION RANGE ALL
TABLE ACCESS FULL DWO DW_ARC_CERRORS 237209 502923 15087690
Can someone tell me why a 'table acess full' is required here?
Thanks in advance,
RajeshSorry, I just found the solution myself. I need to put an extra pair of braces around the set of conditions seperated by OR.
-
Why does it not use the index?
L.S.,
We are using a table called IT_RFC_REGISTRATION. It is a relatively big table for our application.
Its primary key is RFCNR, each new RFCNR getting the next value.
Now for my intranet report I am interested in the last 40 records. But when I execute:
SELECT *
FROM IT_RFC_REGISTRATION
ORDER BY RFCNR DESC
the query takes ages to execute.
When I do this:
SELECT RFCNR
FROM IT_RFC_REGISTRATION
ORDER BY RFCNR DESC
the result comes instantaneous because this query uses the index on RFCNR.
Why does the former query not use the index to execute? It should be much faster to fetch ROWIDs from the index end to start and use those to get the records, than to load all the records and then sort them.
Is there a trick with which I can use a join of the latter query and the former query to speed up the result?
Greetings,
Philbert de Zwart,
Utrecht, The Netherlands.The difference you see in query run time is based on the amount data being sorted, then returned. In the first query, a full table scan is faster since if the index was used, Oracle would have to do a lookup in the index, get the rowid's and go look up the data in the table (TWO disk i/o's). It's faster to just scan the entire table.
Indexes will generally not be used unless you have a where clause. If you only need a few fields from the table, you could include them all in an index. For instance, if you only need RFCNR & DESC create a concatenated index on those two columns and then only a scan of the index is required (very fast). -
How to find out if your query uses the indexes?
How can one tell if the query being issued is using your indexes or doing full table scans?
Thank you.Thank you.
Ok, let me see if I understand it. So, having an
index may not speed things up.True
Full table scans are not bad at all -- as I have it
in my head. The query I ran before was: select *
from table1;In that case an index would only slow things down; you are asking it to get all the information from the table - it has to read all of the table ( a full scan).
>
So full table scans and index have to do with the db
block size and the size of the row correct?
Block size and row size don't have a huge amount to do with it, but they do play a role.
Let me ask: How does one know the size of a row and
then the best option for the db blocks? Block size is a global setting (at the tablespace level I think). You would not likely change the block size based on the average row length in any one table. It would be about the last thing you might look at in terms of tuning (though you might consider it up-front if you had a huge amount of very predictable data).
>
And if, I create indexes and queries have the where
clause and the database uses full table scans then
does it means that either:
The database believes that the best execution plan is
to either do FULL SCANS OR USE INDEXES -- ALL UPTO
THE DATABASE?
No. There is another piece of information that the database needs to make good decisions. If for example you have a WHERE clause "WHERE not_paid = 1" and you have an index on not_paid. To make a good decision the database needs to know about how many of the rows are likely to be not_paid =1. If it's 90% then a full table scan will be cheaper than looking up the addresses of 90% of the rows and then getting the data. If it's 10% using the index will be cheaper. You need to use Analyze Tables to get the database to store this information. Looks like you need to use a bit of time with the manuals.
Jon
-J -
How can i know if my query is using the index ?
Hello...
How can i know if my query is using the index of the table or not?
im using set autotrace on...but is there another way to do it?
thanks!
Alessandro Falanque.Hi,
You can use Explain Plan for checking that your query is using proper index or not. First you need to check that Plan_table is installed in your database or not. If it is not there THEN THE SCRIPT WILL BE LIKE THIS:
CREATE TABLE PLAN_TABLE (
STATEMENT_ID VARCHAR2 (30),
TIMESTAMP DATE,
REMARKS VARCHAR2 (80),
OPERATION VARCHAR2 (30),
OPTIONS VARCHAR2 (30),
OBJECT_NODE VARCHAR2 (128),
OBJECT_OWNER VARCHAR2 (30),
OBJECT_NAME VARCHAR2 (30),
OBJECT_INSTANCE NUMBER,
OBJECT_TYPE VARCHAR2 (30),
OPTIMIZER VARCHAR2 (255),
SEARCH_COLUMNS NUMBER,
ID NUMBER,
PARENT_ID NUMBER,
POSITION NUMBER,
COST NUMBER,
CARDINALITY NUMBER,
BYTES NUMBER,
OTHER_TAG VARCHAR2 (255),
PARTITION_START VARCHAR2 (255),
PARTITION_STOP VARCHAR2 (255),
PARTITION_ID NUMBER,
OTHER LONG,
DISTRIBUTION VARCHAR2 (30))
TABLESPACE SYSTEM NOLOGGING
PCTFREE 10
PCTUSED 40
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 10240
NEXT 10240
PCTINCREASE 50
MINEXTENTS 1
MAXEXTENTS 121
FREELISTS 1 FREELIST GROUPS 1 )
NOCACHE;
After that write the following command in the SQL prompt.
Explain plan for (Select statement);
Select level, SubStr( lpad(' ',2*(Level-1)) || operation || ' ' ||
object_name || ' ' || options || ' ' ||
decode(id, null , ' ', decode(position, null,' ', 'Cost = ' || position) ),1,100)
|| ' ' || nvl(other_tag, ' ') Operation
from PLAN_TABLE
start with id = 0
connect by
prior id = parent_id;
This will show how the query is getting executed . What are all the indexes it is using etc.
Cheers.
Samujjwal Basu -
Why my select is not using the index
This is my index
CREATE INDEX CONFIG_STATE_IDX ON IDENTIFIER
(CONFIGURATION_ID, STATE)
LOGGING
TABLESPACE NII_INDEX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS 2147483645
PCTINCREASE 0
FREELISTS 1
FREELIST GROUPS 1
BUFFER_POOL DEFAULT
NOPARALLEL;
This is my select statement:
SELECT *
FROM identifier i
WHERE
i.configuration_id = '89afead40a0c0b8d00628c59aa405ea4'
AND i.state = 'QT'
AND ROWNUM <6
This is my exmplain plan result
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
SELECT STATEMENT Hint=CHOOSE 5 2128
COUNT STOPKEY
TABLE ACCESS FULL IDENTIFIER 133 K 19 M 2128
Why it is not using the index on configuration_id and state.Possibility one: you didn't do an analyze statistics on the table and/or the index after index creation.
Possibility two: The optimizer has determined that it can return the query result set with fewer I/Os if it does a FTS vs using the index (the optimizer is very keen on I/Os). -
How to use the index method for pathpoints object in illustrator through javascripts
hii...
am using Illustrator CS2 using javascripts...
how to use the index method for pathpoints object in illustrator through javascripts..Hi, what are you trying to do with path points?
CarlosCanto
Maybe you are looking for
-
My phone won't download apps it says waiting loading and then it says it cannot be installed
My phone will not let me download apps anymore I have logged out of iTunes and logged in again but that didn't work. When I try to download apps it will say waiting, installing, then it will start over like 3 times, then it will say unable to downloa
-
Questions on Java Reflection in EJB
Hi, Recently, I use reflection technology on EJB to get/set properties of a bean. We need it because we need to encapsulate data in a map to transfer data between presentation layer and business back end(i.e. the so-called value data object). A bean
-
HOW DO I TURN OFF THE LOW INK WARNING ON MY OFFICEJET 7500A
Hi everyone I have a officejet 7500 all in one printer which is a couple of years old now. I have a ciss system on the printer due to the amount of printing i am now trying to do, however i am now having the really annoying problem of the low ink le
-
Can we push a Custom Type Object on Stack in BCEL?
Hi All, I know how to push Primitive Types on Stack IN BCEL using InstructinoList.append(new PUSH(ConstantPoolGen,343)); Now i want to push Custom Type Object(Obj of some user defined class i.e EngineClass obj) on Stack in BCEL. Let me explain some c
-
I do not want Linkedin or Share on Linkedin on my bar -
I have Share on LinkedIn installed and a Linked in on my upper bar .I want to remove both permanently .Please send me the instructions to get rid of these.