Quantcast
Channel: SCN: Message List - SAP MaxDB
Viewing all articles
Browse latest Browse all 2539

Re: Bad performance with inner join

$
0
0

Hello Stefan,

 

ok now it is clear. The second statement has an equal condition on ERSDA -> so the index AFRU~z02 can be used and this execution is fast.

 

The first statement has an between condition on ERSDA - MaxDb cannot use the complete index AFRU~z02. The optimizer can use only these columns to the between - means of index AFRU~Z02 columes MANDT,WERKS,ERSDA but not the PERSNR anymore. So the optimizer evaluates if the aacess via another index can be used and evaluates index AFRU~Z01 -> here optimizer uses columes Mandt and PERSNR - looks like the PERSNR reducs the number of rows to be read more then reading index AFRU~z02

 

How to optimize this statement:

 

Create an 3. index AFRU~Z03 via the columes PERNR,WERKS,ERSDA

 

The explain must be as follows

AFRU~Z03      using columns PERSNR,WERKS,ERSDA then accessing the table S022

 

MANDT must not be part of this index because mandt is always the first key column and MaxDb uses the key columns as seperator in the index - so you always have the key column in the index as well. ( maxDb ios not working qwith rowids). Ok PERSNR seems to be the column with the most distince values (my experieice) put it as the  first index column. Werks is the second equal condition in the stamtement - so put it as second index column, and at last the column with the between condition.

 

This is the reason why I recommend to create the index with PERSNR,WERKS,ERSDA

 

The explain will look as follows:

AFRU~Z03

PERSNR

WERKS

ERSDA

MANDT ( use key column)

 

join via key range to S022 but only using column MANDT.

 

Ok to optimize the join transition for both statements we have to have a closer look on the join conditions.

 

Mandt =

AUFNR =

VORNR =

 

There seems to be no index on S022 with the columns AUFNR,VORNR

Mandt don't need to be part of the index as well.

 

So please create both indexes as described in my answer - and I'm interesting in the result  ..... could the runtime of both statements be speed up?

 

Regards, Christiane


Viewing all articles
Browse latest Browse all 2539

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>