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

Re: In Hana SQL Script, can I insert records into an already existing table variable?

$
0
0

I wanted to quantify this difference, so I took a stab at it. Used a large dataset, and just performed a couple selects using fiscal year as the filters on each. I ran the same set of SELECTs, just changing the UNION to UNION ALL for the second iteration.

 

Conclusion is that UNION ALL is faster, but almost a negligible amount in this exercise. Likely to increase with result set size, but typically we'll be aggregating somewhat before the union even occurs.

 

SELECT COUNT(*)

FROM "SCHEMA_NAME"."CE12000"

WHERE "GJAHR" IN ('2013','2014')

RESULT -> 1,347,849,619

 

SELECT "GJAHR", "PERIO", "BUKRS", "SPART", "VKORG", "FKART", "WWMDC",SUM ("VVREV"),SUM("VVBBC")

FROM "SCHEMA_NAME"."CE12000"

WHERE "GJAHR" = '2013'

GROUP BY "GJAHR", "PERIO", "BUKRS", "SPART", "VKORG", "FKART","WWMDC"

 

UNION / (UNION ALL in second test)

 

SELECT "GJAHR", "PERIO", "BUKRS", "SPART", "VKORG", "FKART", "WWMDC",SUM ("VVREV"),SUM("VVBBC")

FROM "SCHEMA_NAME"."CE12000"

WHERE "GJAHR" = '2014'

GROUP BY "GJAHR", "PERIO", "BUKRS", "SPART","VKORG","FKART","WWMDC";


UNION DB average = 2.29s

UNION ALL DB average = 2.28s


The main difference from the VizPlan is the aggregation/de-duplication that takes place after the UNION. I was curious how this worked, so here are the plans.


UNION - notice the analytical search present after the union

 

UNION ALL - notice no analytical search, so it saves you the .01s

 

Regards,

Justin


Viewing all articles
Browse latest Browse all 8968

Trending Articles



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