Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> HELP! Full Table Scan
Please help with Oracle doing a FULL TABLE SCAN
I am having problems with Oracle doing a full table scan when (i believe) it shouldn't. Someone please explain why!
The table is called INSURANCE_TRANSACTION and has the following primary key:
ALTER TABLE insurance_transaction
ADD CONSTRAINT pk_insurance_transaction
PRIMARY KEY ( insurance_trans_account_period, insurance_transaction_type, insurance_transaction_batch_no, insurance_transaction_number )
When i do the following select
SELECT count(*)
FROM insurance_transaction
WHERE insurance_trans_account_period = 9610
the quesry uses the index as one would expect.
Explain Plan
SELECT STATEMENT SORT AGGREGATEINDEX RANGE SCAN PK_INSURANCE_TRANSACTION However, when i do the following:
SELECT premium_class_type,count(*)
FROM insurance_transaction WHERE insurance_trans_account_period = 9610 GROUP BY premium_class_type;
It doesn't use the index.
Explain Plan
SELECT STATEMENT SORT GROUP BYTABLE ACCESS FULL INSURANCE_TRANSACTION The Group is disabling it. Can someone explain why this is?
The first query takes 2 seconds, the second query takes 20 minutes.
If i add a hint:
SELECT /*+ INDEX(insurance_transaction pk_insurance_transaction)
premium_class_type,count(*) FROM insurance_transactionWHERE insurance_trans_account_period = 9610 GROUP BY premium_class_type;
Then it DOES use the index, and takes about 2 minutes.
Additional Information
Mike Rushton
mike_at_mrush.demon.co.uk
Received on Fri Dec 06 1996 - 00:00:00 CST
![]() |
![]() |