Is there an option to declare one time at the beginning of the SP that
all the selects will run with NOLOCK command instead of writing if
after each table name?
Thanks.
|
|
0
|
|
|
|
Reply
|
omtechguy
|
2/22/2011 4:40:44 PM |
|
omtechguy wrote:
> Is there an option to declare one time at the beginning of the SP that
> all the selects will run with NOLOCK command instead of writing if
> after each table name?
>
Really? You think this might be a good idea? I don't think it is possible
per se, but you should probably investigate using snapshot isolation if
using SQL 2005 or later.
|
|
0
|
|
|
|
Reply
|
Bob
|
2/22/2011 5:48:48 PM
|
|
omtechguy wrote:
>
> Is there an option to declare one time at the beginning of the SP that
> all the selects will run with NOLOCK command instead of writing if
> after each table name?
>
> Thanks.
Well, you can SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED at the
beginning of the SP. That will apply this transaction isolation level
wherever possible during the scope of the SP.
Please note that you should only do this if you are sure that there are
no data modifications done on those tables during your transactions.
--
Gert-Jan
|
|
0
|
|
|
|
Reply
|
Gert
|
2/22/2011 6:31:11 PM
|
|
On 22 =D7=A4=D7=91=D7=A8=D7=95=D7=90=D7=A8, 20:31, Gert-Jan Strik
<sorrytoomuchspamalre...@xs4all.nl> wrote:
> omtechguy wrote:
>
> > Is there an option to declare one time at the beginning of the SP that
> > all the selects will run with NOLOCK command instead of writing if
> > after each table name?
>
> > Thanks.
>
> Well, you can SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED at the
> beginning of the SP. That will apply this transaction isolation level
> wherever possible during the scope of the SP.
>
> Please note that you should only do this if you are sure that there are
> no data modifications done on those tables during your transactions.
> --
> Gert-Jan
But will is affect only select queries or other too?
|
|
0
|
|
|
|
Reply
|
omtechguy
|
2/22/2011 9:27:41 PM
|
|
omtechguy (omtechguy@gmail.com) writes:
> Is there an option to declare one time at the beginning of the SP that
> all the selects will run with NOLOCK command instead of writing if
> after each table name?
I will be blunt: you should only use NOLOCK if you have full understanding
of the consequences, and it is obvious that you don't.
When using NOLOCK, you may read uncommitted data, but you may also fail
to read *committed* data. You may get faster execution and less blocking,
but what does that help if you get incorrect results.
Overall, understanding the implications of NOLOCK can be difficult also
for an expert. Not the least if there are updates in the mix.
As Bob said, you should investigate snapshot isolation. You may also
need to review indexing to improve performance and reduce blocking
that way.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
|
|
0
|
|
|
|
Reply
|
Erland
|
2/22/2011 11:03:12 PM
|
|
On Feb 22, 1:27=C2=A0pm, omtechguy <omtech...@gmail.com> wrote:
> On 22 =D7=A4=D7=91=D7=A8=D7=95=D7=90=D7=A8, 20:31, Gert-Jan Strik
>
>
>
>
>
> <sorrytoomuchspamalre...@xs4all.nl> wrote:
> > omtechguy wrote:
>
> > > Is there an option to declare one time at the beginning of the SP tha=
t
> > > all the selects will run with NOLOCK command instead of writing if
> > > after each table name?
>
> > > Thanks.
>
> > Well, you can SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED at the
> > beginning of the SP. That will apply this transaction isolation level
> > wherever possible during the scope of the SP.
>
> > Please note that you should only do this if you are sure that there are
> > no data modifications done on those tables during your transactions.
> > --
> > Gert-Jan
>
> But will is affect only select queries or other too?- Hide quoted text -
>
> - Show quoted text -
The TRANSACTION ISOLATION LEVEL is set per connection - this is very
important to understand. Your connection will keep this level unless
another SET statement is issued, or connection is terminated. If you
use pooled connections and don't reset the level before releasing it
back to the pool, then the affected connection will be eventually re-
used by another program or thread etc and results will be messy
|
|
0
|
|
|
|
Reply
|
migurus
|
3/1/2011 11:23:27 PM
|
|
|
5 Replies
196 Views
(page loaded in 0.101 seconds)
Similiar Articles: Wargame of the Year 2009 - Election - comp.sys.ibm.pc.games.war ...... they've outlined 5 years ago, so who knows SP ... popping up explaining that my de facto declaration of ... Vermont sets 'all-time record for one snowstorm'... Accessing "Target Name" Bootline Parameter - comp.os.vxworks ...Last time on comp.os.vxworks, "Michael R. Kesti ... 2002 vs VHDL-93 vs VHDL-87? - comp.lang.vhdl... declaration ... static value that comes as a IN parameter of > > > SP. ... Re: PROC DATASETS but only when no errors - comp.soft-sys.sas ...> >My intermediate files take a long time to create and I end up >combining them all but I do not want to ... WITH (NOLOCK) in Proc SQL - comp.soft-sys.sas Re: PROC DATASETS ... about undefined symbol in module C - comp.lang.asm.x86... mov bp, sp ; base pointer gets stack pointer mov ... I have tried using "C", but it gave out declaration ... First time ... about undefined symbol in module C ... Ron Green paid journalist Heather Kennett to attack Nic Koorey on ...The police investigation will cover that: 1 ... Carl Schapel, Carlo Dottore , Carlo Dottore of NP&SP ... company, third, threaten, tighter, tilt, tim, tim, time ... Mixet.se Media Center - Mixet B2B Marketplace - comp.lang.java.gui ...... Marketplace M=C3=A4rsta, Mixet B2B Marketplace Sp=C3 ... signals, voluntary procedure, mutual creditors, declaration ... corporate events, development events, real- time ... Media Center: Advertising - comp.lang.java.programmer... Marketplace M=C3=A4rsta, Mixet B2B Marketplace Sp=C3 ... signals, voluntary procedure, mutual creditors, declaration ... guide, how to buy diamonds, shopping for the first time ... Using NOLOCK and READPAST table hints in SQL Server | TechRepublicIf you were say returning all the orders created today, at the time there was an uncommitted transaction on one of them. READPAST would skip it, NOLOCK, you might get one ... NOLOCK and ROWLOCK - SQL Server Locks - SQL Server tutorial ...NOLOCK Using NOLOCK politely asks SQL ... For example, if I want to count all users that joined Streamload.com between June 1 ... created at pretty much the same time ... 7/30/2012 9:08:14 AM
|