By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,236 Members | 1,453 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,236 IT Pros & Developers. It's quick & easy.

Query help

P: n/a
Raj
Hi all,

The following query does a table scan, it is only selecting 10% of
tab1's data. It has a clustered index on dt column (not-MDC) and
cluster ratio is 93%

Card of tab1 - 1175070690
Card of tab2 - 100000

Query: ( Tablescan)
select [10-columns] from tab1 where dt >= (select min(dt) from tab2)
Query:( uses the index on dt)
select [10-columns] from tab1 where dt >= (select char(min(dt)) from
tab2)

Actual query:
select .......
(
select .......
union all
select [10-columns] from tab1 where dt >= (select char(min(dt)) from
tab2)
union all
select .......
)
group by .....
Why does the optimizer use the index on the dt column in the second
case??? It also runs faster...

Thanks,
Raj

Aug 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
What is the data type of dt?

Aug 5 '06 #2

P: n/a
Raj
Both are of datatype date...
Tonkuma wrote:
What is the data type of dt?
Aug 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.