patternsqlMinor
Help with interpretation of execution plan (Hash Aggregation)
Viewed 0 times
aggregationwithhelphashplaninterpretationexecution
Problem
So I have an execution plan I'm trying to optimise, and there's a section of an operator I can't quite understand.
There is a section of the plan where a Compute Scalar is used, followed by an aggregation using a hash match.
I have a questions:
How can I use the properties of the hash match aggregator to tell me which columns it is outputting? I can't tell which columns the aggregation is being performed on.
This is the section of the plan:
This is the operator properties:
Plan XML for the element:
```
There is a section of the plan where a Compute Scalar is used, followed by an aggregation using a hash match.
I have a questions:
How can I use the properties of the hash match aggregator to tell me which columns it is outputting? I can't tell which columns the aggregation is being performed on.
This is the section of the plan:
This is the operator properties:
Plan XML for the element:
```
Solution
How can I use the properties of the hash match aggregator to tell me
which columns it is outputting?
It is clearly shown in the output list of your XML. Where you see the expressions you need to work back and find out what the expression definition is.
As I cannot see your full query and execution plan I will use an example to show how you can get that information.
In this case it is
Now if I extend the same query to you will see the column comparisons that you are seeing in your case.
You can see the same in XML.
I can't tell which columns the aggregation is being performed on.
As you said you have distinct in your select statement I am assuming that is why you are seeing the
This article by Paul White gives more insight with complex examples.
This article by Craig Freedman shows example of hash aggregate being used to implement
which columns it is outputting?
It is clearly shown in the output list of your XML. Where you see the expressions you need to work back and find out what the expression definition is.
As I cannot see your full query and execution plan I will use an example to show how you can get that information.
SELECT DISTINCT [PickedQuantity]
FROM [WideWorldImporters].[Sales].[OrderLines]In this case it is
PickedQuantity.Now if I extend the same query to you will see the column comparisons that you are seeing in your case.
SELECT DISTINCT
[PickedQuantity],
[LastEditedBy],
[LastEditedWhen]
FROM
[WideWorldImporters].[Sales].[OrderLines]You can see the same in XML.
I can't tell which columns the aggregation is being performed on.
As you said you have distinct in your select statement I am assuming that is why you are seeing the
Hash Aggregate operator. You can see in the above example use of Hash Aggregate for implementing DISTINCT.This article by Paul White gives more insight with complex examples.
This article by Craig Freedman shows example of hash aggregate being used to implement
DISTINCT.Code Snippets
SELECT DISTINCT [PickedQuantity]
FROM [WideWorldImporters].[Sales].[OrderLines]SELECT DISTINCT
[PickedQuantity],
[LastEditedBy],
[LastEditedWhen]
FROM
[WideWorldImporters].[Sales].[OrderLines]Context
StackExchange Database Administrators Q#173180, answer score: 4
Revisions (0)
No revisions yet.