Home » RDBMS Server » Performance Tuning » How to optimize this sql
How to optimize this sql [message #124926] |
Wed, 22 June 2005 06:27  |
pjsiong
Messages: 3 Registered: June 2005
|
Junior Member |
|
|
Hi, I have a sql which is as follow:
select a.hawb_no,b.chk_out_date
from table_A a ,Table_B b
where a.COMPANY_CODE = 'CT'
and a.EM_DATE between '20050616' and '20050622'
and b.Hawb_No=a.HAWB_NO
and the table_a has company_code+em_date been indexed, table_b
has field hawb_no been indexed.
but the explain plan for this sql always so full scan on table_b
even I have analyze and gather stats for table_b. I expect that the index on table_b should be used for faster execution.
Anyone can help me on this?
Thanks
|
|
|
|
|
|
|
|
|
Re: How to optimize this sql [message #124963 is a reply to message #124931] |
Wed, 22 June 2005 09:41  |
Art Metzer
Messages: 2480 Registered: December 2002
|
Senior Member |
|
|
If EM_DATE holds DATEs, then why is it defined as a VARCHAR2? The optimizer is treating this column like the string it's defined as instead of like the date that it is. Moreover, someday, you will get junk data in that column.
For more information, please read this thread.
|
|
|
Goto Forum:
Current Time: Sat May 03 02:38:26 CDT 2025
|