Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 3587

Re: Optimiser difference : a max() sometimes doing a backward scan and sometimes forward scan

$
0
0

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


Viewing all articles
Browse latest Browse all 3587

Trending Articles