Showing posts with label parameter. Show all posts
Showing posts with label parameter. Show all posts

Thursday, March 29, 2012

export Excel : OmitFormulas

Hi,
The parameter OmitFormulas seem inefficience. All formulas in Report
Designer are transforming to data in Excel and not to formulas.
I'm using SP1 and Excel XP.
Thanks
Tonio (french)I have exactly the opposite problem. I canâ't export Formulas in Excel.
Can you please tell me in which file is that specified?
"tonio932" wrote:
> Hi,
> The parameter OmitFormulas seem inefficience. All formulas in Report
> Designer are transforming to data in Excel and not to formulas.
> I'm using SP1 and Excel XP.
> Thanks
> Tonio (french)|||It's not a parameter in a file but a parameter you can use in the URL of the
report.
You can see "Excel device information settings" in the library for details.
"Soan" wrote:
> I have exactly the opposite problem. I canâ't export Formulas in Excel.
> Can you please tell me in which file is that specified?
>
> "tonio932" wrote:
> > Hi,
> > The parameter OmitFormulas seem inefficience. All formulas in Report
> > Designer are transforming to data in Excel and not to formulas.
> > I'm using SP1 and Excel XP.
> > Thanks
> > Tonio (french)|||I already read it, but i just canâ't understand it. I am using the default RS
interface so I donâ't have idea how can I include it in the URL.
"tonio932" wrote:
> It's not a parameter in a file but a parameter you can use in the URL of the
> report.
> You can see "Excel device information settings" in the library for details.
> "Soan" wrote:
> > I have exactly the opposite problem. I canâ't export Formulas in Excel.
> > Can you please tell me in which file is that specified?
> >
> >
> > "tonio932" wrote:
> >
> > > Hi,
> > > The parameter OmitFormulas seem inefficience. All formulas in Report
> > > Designer are transforming to data in Excel and not to formulas.
> > > I'm using SP1 and Excel XP.
> > > Thanks
> > > Tonio (french)

Friday, March 9, 2012

Expects Parameters When It Should Not

Hi,
I have a stored proc that has one output parameter. When I call
this sp from my client program (an MS Access VBA) it has always worked fine,
but just recently started to give me a message saying that the stored
procedure is expecting a parameter named @.TPRD but did not receive it,
program fails. @.TPRD is the output parameter and is declared as such. I
have not changed the sp recently so there is no code change in the sp. I
do not administrate my SQL Server, but I did request my administrator to
grant me EXEC access to sp_debug so that I could run the stored procedure
debugger. My sp stopped working at about the same time. Do you think
these two events could be related? How to solve? The code for my
stored procedure is below:
ALTER PROCEDURE [ad\jmuseck].[SELECT_TPRD]
@.TPRD VARCHAR(6) OUTPUT
AS
SELECT @.TPRD = TPRD
FROM tblCurrentMonth
RETURN @.TPRD
----
The code in my client MS Access VBA program looks like this:
Function SelectTprd(Optional newval As Variant) As String
Dim cmdCommand As ADODB.Command
Dim prmTPRD As ADODB.Parameter
Set cmdCommand = New ADODB.Command
cmdCommand.ActiveConnection = CurrentProject.AccessConnection
cmdCommand.CommandType = adCmdStoredProc
cmdCommand.CommandText = "SELECT_TPRD"
cmdCommand.Parameters.Refresh
<--STARTED FAILING ON THIS LINE !!
Set prmTPRD = cmdCommand.CreateParameter("@.TPRD", adChar, adParamOutput)
cmdCommand.Execute
'Return the time period to the calling program.'
SelectTprd = cmdCommand.Parameters(1).Value
Set cmdCommand = Nothing 'Free memory
End FunctionHello, Joe
This problem is related to MS Access, more specifically to the OLEDB
provider that Access uses internally. Use one of the following
workarounds:
1. Do not use Parameters.Refresh; instead of this, add each of the
parameters of the stored procedure (even if they have default values)
to the Parameters collection, *in the same order that they are
defined*, using something like this:
cmd.Parameters.Append cmd.CreateParameter("@.ParameterName",...)
2. Use another connection, based on the SQL Server OLEDB provider
(instead of the internal Access OLEDB provider), i.e. instead of the
line:
cmdCommand.ActiveConnection = CurrentProject.AccessConnection
use the following:
cmdCommand.ActiveConnection = CurrentProject.BaseConnectionString
3. If you use at least ADO 2.6, set the NamedParameters property to
True (before setting the ActiveConnection property) and:
a) use Parameters.Refresh (after setting the ActiveConnection) and fill
only the input parameters you need with something like this:
cmd.Parameters("@.ParameterName")=Value
after cmd.Execute, you can get the value of the output parameter by
reffering to it the same way:
Variable=cmd.Parameters("@.ParameterName")
or:
b) do not use Parameters.Refresh, but add the input parameters that you
need (in any order) (it's not necessary to add the input parameters
that have default values) , and also the output parameters (before
setting the ActiveConnection), with something like this:
cmd.Parameters.Append cmd.CreateParameter("@.ParameterName",...)
after cmd.Execute, you can get the value of the output parameter by
reffering to it the same way as above:
Variable=cmd.Parameters("@.ParameterName")
For more informations about the last method, see:
http://msdn.microsoft.com/library/e...dparameters.asp
The easiest method would be the second one (using the
BaseConnectionString to open another connection).
Note: in this message, I wrote about the case when the procedure has
more input parameters, some of them having default values, in addition
to the output parameters. In your case, if you have just one (output)
parameter, some of my remarks do not apply (i.e. adding the parameters
in the same order that they are defined, etc).
Razvan

Expects parameter which was not supplied....need help....

I wanted to add new record into two different tables. By using one web form...
Not so sure I coded it correctly. And I got this error trying to insert new record

" Procedure 'sp_insert' expects parameter '@.mid', which was not supplied. "

Isn't it i have include @.mid in my code ...??

<STORED PROCEDURES>
sp_insert

(
@.mid char(10),
@.status char(10),
@.name char(20),
@.dj char(20),
@.rank char(20),
@.nric char(14),
@.dob char(20),
@.age char(10),
@.add char(80),
@.school char(50),
@.hp char(10),
@.mp char(10),
@.email char(30),
@.pgname char(20),
@.relationship char(20),
@.contact char(10)

)
AS
insert into Table1(mid,status,name,date_joined,rank,nric,dob,age,address,school,house_phone,Mobile_phone,email,[P/G_name],[P/G_relationship],[P/G_contacts])
values (@.mid,@.status,@.name,@.dj,@.rank,@.nric,@.dob,@.age,@.add,@.school,@.hp,@.mp,@.email,@.pgname,@.relationship,@.contact)

insert into Table2 (name) values (@.name)

RETURN

<WEB FORM>
mycommand = New SqlCommand("sp_insert", mycon)
mycommand.CommandType = CommandType.StoredProcedure

Dim midpar As New SqlParameter("@.mid", SqlDbType.Char, 10)
midpar.Direction = ParameterDirection.Input
midpar.Value = Tb1.Text

Dim statuspar As New SqlParameter("@.status", SqlDbType.Char, 10)
statuspar.Direction = ParameterDirection.Input
statuspar.Value = ddl1.SelectedItem.Text

---
---
---Your webform code is wrong, needs to be something like this:

Dim sqlPar As SqlParameter= myCommand.Parameter.Add("@.mid", SqlDbType.Char, 10)
sqlPar.Direction = ParameterDirection.Input
sqlPar.Value = Tb1.Text

sqlPar = myCommand.Parameter.Add("@.status", SqlDbType.Char, 10)
sqlPar.Direction = ParameterDirection.Input
sqlPar.Value = ddl1.SelectedItem.Text


etc.
etc.
etc.

Wednesday, March 7, 2012

Expanding the Multi-Valued Parameter Dropdown Menu

Hello Everyone,

I am trying to expand the multi-valued parameter menu object so I can display the selection list in a more user-friendly format since the text is fairly long. If left at the default setting then I have to scroll to the right to see the complete string(s). For a single-select parameter I can just CAST the string to CHAR(100) and the menu object will expand. However, it seems that this approach is not working for multi-valued parameter menu objects.

Is this a bug in SSRS, and is there another way to accomplish this. Please let me know.

Thank You!!!

I apologize for bumping this topic, but could some of the Microsoft guys
please let me know if this is possible. I'm sure I'm not the only one trying this. Thank you so much!

Expanding the Multi-Valued Parameter Dropdown Menu

Hello Everyone,

I am trying to expand the multi-valued parameter menu object so I can display the selection list in a more user-friendly format since the text is fairly long. If left at the default setting then I have to scroll to the right to see the complete string(s). For a single-select parameter I can just CAST the string to CHAR(100) and the menu object will expand. However, it seems that this approach is not working for multi-valued parameter menu objects.

Is this a bug in SSRS, and is there another way to accomplish this. Please let me know.

Thank You!!!

I apologize for bumping this topic, but could some of the Microsoft guys
please let me know if this is possible. I'm sure I'm not the only one trying this. Thank you so much!

Sunday, February 26, 2012

Expand All/Collapse All Toggle

I have implemented all of the suggestions to create an Expand All/Collapse All toggle on a couple of my reports that have Drilldown using a parameter to control it. But, I have an issue with figuring out how to create a link or button on the reports that can be clicked to set the parameter value appropriately? When I render reports in my application I use the RS2005 ReportViewer control in VS2005, but I do not show the parameter bar in the viewer at all and don't want to.

Is there a way to set the value of the parameter within the Body of the report and then cause the report to render again with that new value?

Thanks,

Steve

I figured it out on my own. I just added the textboxes to the report and set the Action on the textbox to link back to itself and change the ExpandAllToggle parameter to the other value.

Friday, February 24, 2012

Exeption MSDE "Maximum length is 128"

I am using a SProc to update some fields in a database. The field I am updating is a comment field. When I pass the parameter by doing a Command.ExecuteNonQuery I get an exception that says my parameter is greater than 128. The field it is updating is a nvarchar with a length of 500. I found anarticle on Microsoft's website that is alluding to the fact that a "name" cannot be greater than 128. How else can I do an update of this size? I would like to use a SProc. I am still learning SQL 2000 and MSDE so this may be an easy fix. Here is the exception I am getting: "The identifier that starts with 'My data thats needs to be updated to the database' is too long. Maximum length is 128." -VBJBdpends on the variable that is holding the value. where is the comment coming from ? a textbox ?|||Yes the comment is comming from a textbox that is in a asp.net form.

Sunday, February 19, 2012

Execution snapshots and datetime

Hello, I need some help with a problem i'm encountering:
I have a parameter named "startDate" defined in a report. The data type for
this parameter is DateTime and the default value I set in the report is
Non-queried with =Now() as the value. This value is sent to a SQL sProc.
When I run the report through my ASP.net page, it displays nicely.
I'm trying to use execution snapshots for this report with nightly email
subscriptions because the report returns large amounts of data and we can't
have it process the report at peak business hours. However when I try to set
up execution snapshots with this report, and set the startDate parameter
default value to =Now() in Report Manager, I get the error of "The property
of report parameter startDate doesn't have the expected type."
So then I changed the data type for parameter startDate to String and set
the value to =Now() in Report manager. At least now it takes the value. But
when trying to setup the snapshot again, I receive "Syntax error converting
datetime from character string" even though I use the convert function in
the SQL sProc. I need the snapshot to generate reports on a per week basis
and I can't hardcode a date in the parameter field like "9/9/2004". It has
to be =Now() so it can generate a snapshot per week automatically with that
weeks data. I've tried everything and i can't get it to work. Is there
anyway I can get Now() or DateAdd() to work in a datetime (or string if I
have to) field using execution snapshots? thank youYou cannot change an expression-based default value once the report is
published on the report server. When you type in =Now, then it is
interpreted as string "=Now" and *not* as expression.
You will need delete the report from report server, load the RDL file in
report designer, set the expression-based default value there (e.g. =Now or
=Today) and then republish the report to the report server.
Then you should be able to create execution snapshots without any issues.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Mark" <idroppeddabomb@.hotmail.com> wrote in message
news:eq5E2bplEHA.1652@.TK2MSFTNGP09.phx.gbl...
> Hello, I need some help with a problem i'm encountering:
> I have a parameter named "startDate" defined in a report. The data type
for
> this parameter is DateTime and the default value I set in the report is
> Non-queried with =Now() as the value. This value is sent to a SQL sProc.
> When I run the report through my ASP.net page, it displays nicely.
> I'm trying to use execution snapshots for this report with nightly email
> subscriptions because the report returns large amounts of data and we
can't
> have it process the report at peak business hours. However when I try to
set
> up execution snapshots with this report, and set the startDate parameter
> default value to =Now() in Report Manager, I get the error of "The
property
> of report parameter startDate doesn't have the expected type."
> So then I changed the data type for parameter startDate to String and set
> the value to =Now() in Report manager. At least now it takes the value.
But
> when trying to setup the snapshot again, I receive "Syntax error
converting
> datetime from character string" even though I use the convert function in
> the SQL sProc. I need the snapshot to generate reports on a per week basis
> and I can't hardcode a date in the parameter field like "9/9/2004". It has
> to be =Now() so it can generate a snapshot per week automatically with
that
> weeks data. I've tried everything and i can't get it to work. Is there
> anyway I can get Now() or DateAdd() to work in a datetime (or string if I
> have to) field using execution snapshots? thank you
>

Execution Snapshot - Parameter "gray out"

Hi Experts,
I got a report that takes in a parameter and run normally 20 min to produce
the result. So I decide to take advantage of Execution Snapshot feature. I
create a shared schedule and set my Execution Snapshot to execute every
morning around 1 am with default parameter. The next day I go into the report
and run it and wow it just takes second to produce the result, I'm impressed.
But I noticed something strange: the report runs using my default parameter
and the parameter box is "gray out". So I cannot run the report again using
different parameter value other than the default one.
I'm using Reporting Services Standard edition. Is this behavior normal for
this edition? Does the Enterprise edition allow me to change the parameter
once it's already scheduled for Execution Snapshot.
Any idea?
ThanhThanh,
It is normal behavior. Snapshots run for the default parameter values and
stores the intermediate report format /data in cache. When you go back to
the report, it grabs the intermediate format from cache and presents it,
preventing another trip to the database. If it allowed you to change the
parameters, it would need to re-execute the report with the new query
parameters.
If you want the parameters to be available, you need to move from using
query parameters to using report filters. There are plusses and minuses to
using report filters.
Books on line has some good info on how to use report filters.
--
Andy Potter
blog: http://sqlreportingservices.spaces.live.com/
"Thanh Nguyen" wrote:
> Hi Experts,
> I got a report that takes in a parameter and run normally 20 min to produce
> the result. So I decide to take advantage of Execution Snapshot feature. I
> create a shared schedule and set my Execution Snapshot to execute every
> morning around 1 am with default parameter. The next day I go into the report
> and run it and wow it just takes second to produce the result, I'm impressed.
> But I noticed something strange: the report runs using my default parameter
> and the parameter box is "gray out". So I cannot run the report again using
> different parameter value other than the default one.
> I'm using Reporting Services Standard edition. Is this behavior normal for
> this edition? Does the Enterprise edition allow me to change the parameter
> once it's already scheduled for Execution Snapshot.
> Any idea?
> Thanh

Wednesday, February 15, 2012

Execution penalty depending on column size

Hello!
Yesterday we were reported a problem when querying a particular item in =
a =
table:
SELECT * FROM [Parameter]
WHERE Parameter.ParameterID IN (
SELECT DISTINCT V.ParameterID
FROM Sample AS S
INNER JOIN [Value] AS V ON S.SampleID =3D V.SampleID
INNER JOIN Buoy ON S.BuoyID =3D Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
)
The preceding query times out and never returns a value.
When Buoy.BuoyID equals a lower number (e.g. 470000) it works fine and =
returns the expected result. The set of data associated to each buoy is =
=
similar in size.
A strange thing is that when the execution plan for key 470000 is =
DIFFERENT from the execution plan for 2922594.
Another curious behaviour is that when the query is executed with =
Buoy.BuoyID IN (470000, 2922594) it works fine and with a similar plan t=
o =
the 470000 case.
When we tested with Buoy.BuoyID IN (1922594) that does not exist in the =
=
database, the execution plan was equal to the pathological case.
We replaced the preceding query for
SELECT * FROM [Parameter] P WHERE P.ParameterID IN(
SELECT V.ParameterID
FROM Sample AS S
LEFT JOIN [Value] AS V ON S.SampleID =3D V.SampleID
LEFT JOIN Buoy ON S.BuoyID =3D Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
GROUP BY V.ParameterID
)
which works in all the situations and with improved performance.
Can you help us on what is happening with the first query that executes =
=
fine with all the buoys except that particular one? And why does the =
execution plan changes when the size of the number increases from 470000=
=
to 2922594?
Thanks for your help! Sounds like param sniffing issues. Have a look at this document for more
details:
http://www.microsoft.com/technet/pr...005/recomp.mspx
Andrew J. Kelly SQL MVP
"Gerardo Gonzlez" <ggonzalez@.odyssey.com.uy> wrote in message
news:op.ts85v9dflva8xe@.sapereaude...
Hello!
Yesterday we were reported a problem when querying a particular item in a
table:
SELECT * FROM [Parameter]
WHERE Parameter.ParameterID IN (
SELECT DISTINCT V.ParameterID
FROM Sample AS S
INNER JOIN [Value] AS V ON S.SampleID = V.SampleID
INNER JOIN Buoy ON S.BuoyID = Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
)
The preceding query times out and never returns a value.
When Buoy.BuoyID equals a lower number (e.g. 470000) it works fine and
returns the expected result. The set of data associated to each buoy is
similar in size.
A strange thing is that when the execution plan for key 470000 is
DIFFERENT from the execution plan for 2922594.
Another curious behaviour is that when the query is executed with
Buoy.BuoyID IN (470000, 2922594) it works fine and with a similar plan to
the 470000 case.
When we tested with Buoy.BuoyID IN (1922594) that does not exist in the
database, the execution plan was equal to the pathological case.
We replaced the preceding query for
SELECT * FROM [Parameter] P WHERE P.ParameterID IN(
SELECT V.ParameterID
FROM Sample AS S
LEFT JOIN [Value] AS V ON S.SampleID = V.SampleID
LEFT JOIN Buoy ON S.BuoyID = Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
GROUP BY V.ParameterID
)
which works in all the situations and with improved performance.
Can you help us on what is happening with the first query that executes
fine with all the buoys except that particular one? And why does the
execution plan changes when the size of the number increases from 470000
to 2922594?
Thanks for your help! |||Hello Andrew, I'm Gerardo's partner. I didn't find anything in the paper
that pointed to parameter sniffing as a cause for degraded performance in
a query.
I want to know if it's normal for a query to change its execution plan
based on the values of it's parameters...that's what's happening here, we
have the same query with two wildly differing execution plans depending
only on a single value (that's being matched to a Primary key).
Many thanks for your help,
Pablo
--
I'm glad my Mom was pro-life.
Pablo Montilla
www.odyssey.com.uy|||Not sure if batch queries can be 'forcibly recompiled' for each execution.
If you put the code into a sproc, you CAN do this, using the WITH RECOMPILE
option. This will ensure a fresh query plan is generated for every call and
is a normal action to respond to varying parameter value performance issues.
TheSQLGuru
President
Indicium Resources, Inc.
"Pablo Montilla" <melkor@.odyssey.com.uy> wrote in message
news:op.ts897ujmcj6shk@.chimera.odyssey.com.uy...
> Hello Andrew, I'm Gerardo's partner. I didn't find anything in the paper
> that pointed to parameter sniffing as a cause for degraded performance in
> a query.
> I want to know if it's normal for a query to change its execution plan
> based on the values of it's parameters...that's what's happening here, we
> have the same query with two wildly differing execution plans depending
> only on a single value (that's being matched to a Primary key).
> Many thanks for your help,
> Pablo
> --
>
> I'm glad my Mom was pro-life.
> Pablo Montilla
> www.odyssey.com.uy|||In addition to the other replies: make sure the index statistics are up
to date. When in doubt, update them WITH FULLSCAN.
Gert-Jan
Gerardo Gonzlez wrote:
> Hello!
> Yesterday we were reported a problem when querying a particular item in a
> table:
> SELECT * FROM [Parameter]
> WHERE Parameter.ParameterID IN (
> SELECT DISTINCT V.ParameterID
> FROM Sample AS S
> INNER JOIN [Value] AS V ON S.SampleID = V.SampleID
> INNER JOIN Buoy ON S.BuoyID = Buoy.BuoyID
> WHERE Buoy.BuoyID IN (2922594)
> )
> The preceding query times out and never returns a value.
> When Buoy.BuoyID equals a lower number (e.g. 470000) it works fine and
> returns the expected result. The set of data associated to each buoy is
> similar in size.
> A strange thing is that when the execution plan for key 470000 is
> DIFFERENT from the execution plan for 2922594.
> Another curious behaviour is that when the query is executed with
> Buoy.BuoyID IN (470000, 2922594) it works fine and with a similar plan to
> the 470000 case.
> When we tested with Buoy.BuoyID IN (1922594) that does not exist in the
> database, the execution plan was equal to the pathological case.
> We replaced the preceding query for
> SELECT * FROM [Parameter] P WHERE P.ParameterID IN(
> SELECT V.ParameterID
> FROM Sample AS S
> LEFT JOIN [Value] AS V ON S.SampleID = V.SampleID
> LEFT JOIN Buoy ON S.BuoyID = Buoy.BuoyID
> WHERE Buoy.BuoyID IN (2922594)
> GROUP BY V.ParameterID
> )
> which works in all the situations and with improved performance.
> Can you help us on what is happening with the first query that executes
> fine with all the buoys except that particular one? And why does the
> execution plan changes when the size of the number increases from 470000
> to 2922594?
> Thanks for your help! |||The section on Parameter sniffing makes it clear that the plan is based on
the value you pass to the sp the first time it is run or the first time it
is marked for recompiles. So if one value works best as a scan because it
returns many rows the plan will be bad for one that returns only a few rows
and visa versa. There must be more to this than you say because the
optimizer would know there is only one row that matches a PK and would
produce the same query each time regardless of the value. Is there a PK
constraint on the PK column? Have statistics been disabled for that column
or table? I think we need to see the actual query along with the DDL for
the tables accessed.
Andrew J. Kelly SQL MVP
"Pablo Montilla" <melkor@.odyssey.com.uy> wrote in message
news:op.ts897ujmcj6shk@.chimera.odyssey.com.uy...
> Hello Andrew, I'm Gerardo's partner. I didn't find anything in the paper
> that pointed to parameter sniffing as a cause for degraded performance in
> a query.
> I want to know if it's normal for a query to change its execution plan
> based on the values of it's parameters...that's what's happening here, we
> have the same query with two wildly differing execution plans depending
> only on a single value (that's being matched to a Primary key).
> Many thanks for your help,
> Pablo
> --
>
> I'm glad my Mom was pro-life.
> Pablo Montilla
> www.odyssey.com.uy|||I'll check those things with Gerardo and reply you.
Many thanks for your answer!
Regards,
Pablo
--
I've fallen... and can't BOOT up!
Pablo Montilla
www.odyssey.com.uy

Execution penalty depending on column size

Hello!
Yesterday we were reported a problem when querying a particular item in = a =
table:
SELECT * FROM [Parameter]
WHERE Parameter.ParameterID IN (
SELECT DISTINCT V.ParameterID
FROM Sample AS S
INNER JOIN [Value] AS V ON S.SampleID =3D V.SampleID
INNER JOIN Buoy ON S.BuoyID =3D Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
)
The preceding query times out and never returns a value.
When Buoy.BuoyID equals a lower number (e.g. 470000) it works fine and =
returns the expected result. The set of data associated to each buoy is = =
similar in size.
A strange thing is that when the execution plan for key 470000 is =
DIFFERENT from the execution plan for 2922594.
Another curious behaviour is that when the query is executed with =
Buoy.BuoyID IN (470000, 2922594) it works fine and with a similar plan t= o =
the 470000 case.
When we tested with Buoy.BuoyID IN (1922594) that does not exist in the = =
database, the execution plan was equal to the pathological case.
We replaced the preceding query for
SELECT * FROM [Parameter] P WHERE P.ParameterID IN(
SELECT V.ParameterID
FROM Sample AS S
LEFT JOIN [Value] AS V ON S.SampleID =3D V.SampleID
LEFT JOIN Buoy ON S.BuoyID =3D Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
GROUP BY V.ParameterID
)
which works in all the situations and with improved performance.
Can you help us on what is happening with the first query that executes = =
fine with all the buoys except that particular one? And why does the =
execution plan changes when the size of the number increases from 470000= =
to 2922594?
Thanks for your help! :)Sounds like param sniffing issues. Have a look at this document for more
details:
http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
--
Andrew J. Kelly SQL MVP
"Gerardo González" <ggonzalez@.odyssey.com.uy> wrote in message
news:op.ts85v9dflva8xe@.sapereaude...
Hello!
Yesterday we were reported a problem when querying a particular item in a
table:
SELECT * FROM [Parameter]
WHERE Parameter.ParameterID IN (
SELECT DISTINCT V.ParameterID
FROM Sample AS S
INNER JOIN [Value] AS V ON S.SampleID = V.SampleID
INNER JOIN Buoy ON S.BuoyID = Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
)
The preceding query times out and never returns a value.
When Buoy.BuoyID equals a lower number (e.g. 470000) it works fine and
returns the expected result. The set of data associated to each buoy is
similar in size.
A strange thing is that when the execution plan for key 470000 is
DIFFERENT from the execution plan for 2922594.
Another curious behaviour is that when the query is executed with
Buoy.BuoyID IN (470000, 2922594) it works fine and with a similar plan to
the 470000 case.
When we tested with Buoy.BuoyID IN (1922594) that does not exist in the
database, the execution plan was equal to the pathological case.
We replaced the preceding query for
SELECT * FROM [Parameter] P WHERE P.ParameterID IN(
SELECT V.ParameterID
FROM Sample AS S
LEFT JOIN [Value] AS V ON S.SampleID = V.SampleID
LEFT JOIN Buoy ON S.BuoyID = Buoy.BuoyID
WHERE Buoy.BuoyID IN (2922594)
GROUP BY V.ParameterID
)
which works in all the situations and with improved performance.
Can you help us on what is happening with the first query that executes
fine with all the buoys except that particular one? And why does the
execution plan changes when the size of the number increases from 470000
to 2922594?
Thanks for your help! :)|||Hello Andrew, I'm Gerardo's partner. I didn't find anything in the paper
that pointed to parameter sniffing as a cause for degraded performance in
a query.
I want to know if it's normal for a query to change its execution plan
based on the values of it's parameters...that's what's happening here, we
have the same query with two wildly differing execution plans depending
only on a single value (that's being matched to a Primary key).
Many thanks for your help,
Pablo
--
I'm glad my Mom was pro-life.
Pablo Montilla
www.odyssey.com.uy|||Not sure if batch queries can be 'forcibly recompiled' for each execution.
If you put the code into a sproc, you CAN do this, using the WITH RECOMPILE
option. This will ensure a fresh query plan is generated for every call and
is a normal action to respond to varying parameter value performance issues.
--
TheSQLGuru
President
Indicium Resources, Inc.
"Pablo Montilla" <melkor@.odyssey.com.uy> wrote in message
news:op.ts897ujmcj6shk@.chimera.odyssey.com.uy...
> Hello Andrew, I'm Gerardo's partner. I didn't find anything in the paper
> that pointed to parameter sniffing as a cause for degraded performance in
> a query.
> I want to know if it's normal for a query to change its execution plan
> based on the values of it's parameters...that's what's happening here, we
> have the same query with two wildly differing execution plans depending
> only on a single value (that's being matched to a Primary key).
> Many thanks for your help,
> Pablo
> --
>
> I'm glad my Mom was pro-life.
> Pablo Montilla
> www.odyssey.com.uy|||In addition to the other replies: make sure the index statistics are up
to date. When in doubt, update them WITH FULLSCAN.
Gert-Jan
Gerardo González wrote:
> Hello!
> Yesterday we were reported a problem when querying a particular item in a
> table:
> SELECT * FROM [Parameter]
> WHERE Parameter.ParameterID IN (
> SELECT DISTINCT V.ParameterID
> FROM Sample AS S
> INNER JOIN [Value] AS V ON S.SampleID = V.SampleID
> INNER JOIN Buoy ON S.BuoyID = Buoy.BuoyID
> WHERE Buoy.BuoyID IN (2922594)
> )
> The preceding query times out and never returns a value.
> When Buoy.BuoyID equals a lower number (e.g. 470000) it works fine and
> returns the expected result. The set of data associated to each buoy is
> similar in size.
> A strange thing is that when the execution plan for key 470000 is
> DIFFERENT from the execution plan for 2922594.
> Another curious behaviour is that when the query is executed with
> Buoy.BuoyID IN (470000, 2922594) it works fine and with a similar plan to
> the 470000 case.
> When we tested with Buoy.BuoyID IN (1922594) that does not exist in the
> database, the execution plan was equal to the pathological case.
> We replaced the preceding query for
> SELECT * FROM [Parameter] P WHERE P.ParameterID IN(
> SELECT V.ParameterID
> FROM Sample AS S
> LEFT JOIN [Value] AS V ON S.SampleID = V.SampleID
> LEFT JOIN Buoy ON S.BuoyID = Buoy.BuoyID
> WHERE Buoy.BuoyID IN (2922594)
> GROUP BY V.ParameterID
> )
> which works in all the situations and with improved performance.
> Can you help us on what is happening with the first query that executes
> fine with all the buoys except that particular one? And why does the
> execution plan changes when the size of the number increases from 470000
> to 2922594?
> Thanks for your help! :)|||The section on Parameter sniffing makes it clear that the plan is based on
the value you pass to the sp the first time it is run or the first time it
is marked for recompiles. So if one value works best as a scan because it
returns many rows the plan will be bad for one that returns only a few rows
and visa versa. There must be more to this than you say because the
optimizer would know there is only one row that matches a PK and would
produce the same query each time regardless of the value. Is there a PK
constraint on the PK column? Have statistics been disabled for that column
or table? I think we need to see the actual query along with the DDL for
the tables accessed.
--
Andrew J. Kelly SQL MVP
"Pablo Montilla" <melkor@.odyssey.com.uy> wrote in message
news:op.ts897ujmcj6shk@.chimera.odyssey.com.uy...
> Hello Andrew, I'm Gerardo's partner. I didn't find anything in the paper
> that pointed to parameter sniffing as a cause for degraded performance in
> a query.
> I want to know if it's normal for a query to change its execution plan
> based on the values of it's parameters...that's what's happening here, we
> have the same query with two wildly differing execution plans depending
> only on a single value (that's being matched to a Primary key).
> Many thanks for your help,
> Pablo
> --
>
> I'm glad my Mom was pro-life.
> Pablo Montilla
> www.odyssey.com.uy|||I'll check those things with Gerardo and reply you.
Many thanks for your answer!
Regards,
Pablo
--
I've fallen... and can't BOOT up!
Pablo Montilla
www.odyssey.com.uy