Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

SQL Execution plan differences

$
0
0

Hi folks,

 

I have a feeling this question is right up Lars alley.  I have a view where the user enters a posting date such as 02/01/2013.  The view utilizes MKPF and MSEG and each are partitioned by MJAHR which is year such as '2013' as MJAHR is one of the primary keys in both tables.  The performance is great when the user includes the year in their selections.  However, since they are already choosing posting date we would like to simply extract the YEAR from their posting date selection.  We have the code working however the problem is that the execution time takes twice as long.  To get to the root of the problem I dissected the execution plan which was quite complex so as a test I created a much more simple SQL and compared the two to see why they were executing differently.  In my dumbed down example below it actually takes 7 times as long to extract the year from the posting date!  It seems the bulk of the problem is with the JEDistinctAttribute step of column search as well as the REDUCTION PHASE step of the column search.  When comparing the two SQL execution plans visually they each have the exact same amount of boxes however the slow version is simply taking a lot longer for nearly each and every step.  Here's examples;

 

CODE THAT RUNS IN 1.5 SECONDS

 

 

selecthdr.MBLNR
from"MYSCHEMA"."MKPF"hdr

JOIN "MYSCHEMA"."MSEG" mat ON hdr.MBLNR = mat.MBLNR

where(

hdr.MJAHR = '2013'

  and hdr.BUDAT between TO_DATE('02-01-2013','MM-DD-YYYY') and TO_DATE('02-01-2013','MM-DD-YYYY')

   and mat.BWART = 'MyMovementType'

and mat.WERKS = 'MyPlant')

   GROUP BY hdr.MBLNR

 

CODE THAT DERIVES YEAR FROM POSTING DATE RUNS IN 7.5 SECONDS

 

selecthdr.MBLNR
from"MYSCHEMA"."MKPF"a11

JOIN "MYSCHEMA"."MSEG" mat ON hdr.MBLNR = mat.MBLNR

where(

hdr.MJAHR between YEAR (TO_DATE('02-01-2013','MM-DD-YYYY')) and YEAR (TO_DATE('02-01-2013','MM-DD-YYYY'))

  and hdr.BUDAT between TO_DATE('02-01-2013','MM-DD-YYYY') and TO_DATE('02-01-2013','MM-DD-YYYY')

   and mat.BWART = 'MyMovementType'

and mat.WERKS = 'MyPlant')

   GROUP BY hdr.MBLNR

 

Do you see any obvious problems with the slower SQL statement?  Strangely in many of the JEDistinctAttribute step the 'number of minitasks' in the second SQL execution plan are often many times larger than the first but I'm not clear why.  I figured I would post this here before creating a message with SAP.  Thanks for any help or insight!

 

-Patrick


Viewing all articles
Browse latest Browse all 5653

Trending Articles



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