Further to this we have a large table and we simply want to run
select @x = min(EXTERNAL_ID)
from EXTERNAL_ID
where EXT_ID = "IDENTIFIER"
and EXT_ID_TYPE = 'B2'
and EXTERNAL_ID_TYPE = 'A1'
As soon as we use the MIN then we get the scanning of the table where as
select @x = EXTERNAL_ID
from EXTERNAL_ID
where EXT_ID = "IDENTIFIER"
and EXT_ID_TYPE = 'B2'
and EXTERNAL_ID_TYPE = 'A1'
runs fine.
Is there any optimiser hints we can add to make this quick ?
At present we're having to use a temporary table - which is really awful solution
select EXTERNAL_ID
into #x
from EXTERNAL_ID
where EXT_ID = "IDENTIFIER"
and EXT_ID_TYPE = 'B2'
and EXTERNAL_ID_TYPE = 'A1'
select min(EXTERNAL_ID) from #x
Thanks