Hi everyone,
Recently I experienced a situation with my report which has 2 report parameters mapped to 2 query parameters.My DataSet is populated by a query which performs select statement with 3 union operators
select...
union
select
union
...
In the dataset query I reference the query parameters multiple times and eventually the performance degraded. Then I declared two variables in my dataset query and refenced the sql variables in my script instead of the query parameters and it worked several times faster:
DECLARE @var1
set @var1= @queryparam1
DECLARE @var2
set @var2= @queryparam2
Can someone please explain this behavior of the parameter values? Why a variable declared in my sql appears to work much faster then referencing a query parameter? Does this mean that my query is making multiple roundtrips when the query parameter is referenced multiple time?
Thanks in adavance,