Re: Help me convince the dev manager. Please.
From: Rohan Hattangdi (RohanHattangdi2003_at_hotmail.com)
Date: 05/12/04
- Next message: Tom Moreau: "Re: Validation query"
- Previous message: David Schleifer [MSFT]: "Re: Concatenation help needed."
- In reply to: Aaron Bertrand - MVP: "Re: Help me convince the dev manager. Please."
- Next in thread: David Browne: "Re: Help me convince the dev manager. Please."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 12 May 2004 18:51:14 -0400
I tried this with a simple example in Northwind and it shows an index scan
same as the method with the non-sargable clause - just as it would appear
you see in your database.
I will try this with a larger query to see where it goes.
I can not really use NOLOCK because dirty reads will be an issue for our
data except in a certain small number of cases.
Like I mentioned before, I do not want this to be a "put on the blinders"
and follow this rule sort of thing. I suppose I must have come off like that
in my initial post.
I just want people to consider dynamic SQL as an alternate to using the
non-sargable clauses they are using now.
Rohan
"Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
news:eiIl3CGOEHA.128@TK2MSFTNGP12.phx.gbl...
> > <column name> = ISNULL(<var name>, <column name>)
> >
> > The variable has a default of NULL. If the optional parameter is not
> passed
> > in, the column matches itself.
> >
> > This is causing index scans instead of seeks. It is causing an excessive
> > number of locks to be acquired. Our database servers are already under a
> > large load ... the locks get escalated and cause blocking and
dead-locks.
>
> I haven't tested this thoroughly, but have you checked out the
implications
> of changing the ISNULL to WHERE col = CASE WHEN @param IS NOT NULL THEN
> @param ELSE col END? On my small resultset the execution plans looked the
> same, but maybe in your result they would be different.
>
> What about using NOLOCK on the queries? I know this is not a recommended
> approach but if you can sacrifice dirty reads in order to eliminate
locking
> and blocking, that might be a better approach than forcing everyone to
write
> dynamic SQL.
>
> I am not 100% opposed to dynamic SQL but I know there are other ways you
can
> try to improve performance without forcing that hand...
>
> --
> Aaron Bertrand
> SQL Server MVP
> http://www.aspfaq.com/
>
>
- Next message: Tom Moreau: "Re: Validation query"
- Previous message: David Schleifer [MSFT]: "Re: Concatenation help needed."
- In reply to: Aaron Bertrand - MVP: "Re: Help me convince the dev manager. Please."
- Next in thread: David Browne: "Re: Help me convince the dev manager. Please."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|