Subject | IN optimization - continued |
---|---|
Author | Gary Benade |
Post date | 2005-03-23T07:38:05Z |
Apologies, my cat hit send before I could finish....
Would it not be possible for the optimiser to recognise these two queries as
the same and use the same plan?
select * from customers
where link in
('NOR0000001')
[ 1 indexed table read]
select * from customers
where link in
(select link from customers
where link = 'NOR0000001')
[ 12600 natural table read + 12600 indexed table reads]!!!!!
I can understand if the IN clause has a reference to the master table - as
in
select * from customers c
where c.link in
(select link from customers
where link = c.link)
Its a silly example but it demonstrates the problem. Re-evaluating the in
clause would be necessary in this case, but if the IN clause is static is
makes sense to run it once and apply it to the master table.
Would it not be possible for the optimiser to recognise these two queries as
the same and use the same plan?
select * from customers
where link in
('NOR0000001')
[ 1 indexed table read]
select * from customers
where link in
(select link from customers
where link = 'NOR0000001')
[ 12600 natural table read + 12600 indexed table reads]!!!!!
I can understand if the IN clause has a reference to the master table - as
in
select * from customers c
where c.link in
(select link from customers
where link = c.link)
Its a silly example but it demonstrates the problem. Re-evaluating the in
clause would be necessary in this case, but if the IN clause is static is
makes sense to run it once and apply it to the master table.