Wednesday, March 7, 2012

nolock

Hi,
i wonder how to set the nolock option.
if i use subviews do i have to go througg all of them to find all
tables and add nolock or does it affect the subqueries automatically?
is there a database switch i can set which
affects all select statements if that wont work to save time
select vp_id, Sum(summe_drawing) as summe_drawing, sum(summe_opp) as
summe_opp, sum(summe_quota) as summe_quota, product_id
from mpc_draw_opp_quota_v (nolock) '
greets mikeWhen specifying join hints use the WITH keyword, e.g.
select <column list>
from <table> with(<hint> [, ...])
Specify hints for all tables in the from clause, but be really, really
careful when using hints - they might have a negative impact on performance
and/or yield unexpected results.
ML
http://milambda.blogspot.com/|||set transaction isolation level read uncommitted
select * from yourview
Tony.
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
<peppi911@.hotmail.com> wrote in message
news:1137681397.337443.5080@.z14g2000cwz.googlegroups.com...
> Hi,
> i wonder how to set the nolock option.
> if i use subviews do i have to go througg all of them to find all
> tables and add nolock or does it affect the subqueries automatically?
> is there a database switch i can set which
> affects all select statements if that wont work to save time
> select vp_id, Sum(summe_drawing) as summe_drawing, sum(summe_opp) as
> summe_opp, sum(summe_quota) as summe_quota, product_id
> from mpc_draw_opp_quota_v (nolock) '
> greets mike
>|||NOLOCK will make your queries return incorrect results at lightning speed.
You shouldn't use it unless there is an overwhelming need to do so, or if
the impact of changes is minimal: for example, if you're computing an
average based on thousands of rows, it doesn't really matter if a few rows
are modified during the calculation. Under no circumstances should you use
NOLOCK to compute changes that are about to be applied to the database,
unless you use some other mechanism to serialize access to the source
tables. For example, if you're calculating payroll, and a change to an
employee's salary is rolled back after it's read out, then the amounts on
the paycheck will be incorrect. If, on the other hand, you use an
application lock to block updates to the employee table during the payroll
calculation, then you can use NOLOCK.
The READ UNCOMMITTED isolation level and the NOLOCK hint are often misused
by neophytes in an attempt to improve performance or to deal with deadlocks.
SQL Server 2005 has a new isolation level READ COMMITTED SNAPSHOT which can
be used to improve the performance of database queries and to reduce
blocking and deadlocks because it does not apply locks. It should NOT be
used to calculate changes to the database, however, because it's possible
for the information read out to become stale by the time the changes are
committed.
<peppi911@.hotmail.com> wrote in message
news:1137681397.337443.5080@.z14g2000cwz.googlegroups.com...
> Hi,
> i wonder how to set the nolock option.
> if i use subviews do i have to go througg all of them to find all
> tables and add nolock or does it affect the subqueries automatically?
> is there a database switch i can set which
> affects all select statements if that wont work to save time
> select vp_id, Sum(summe_drawing) as summe_drawing, sum(summe_opp) as
> summe_opp, sum(summe_quota) as summe_quota, product_id
> from mpc_draw_opp_quota_v (nolock) '
> greets mike
>

No comments:

Post a Comment