SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


NOLOCK/Isoloatin Level for READONLY database


NOLOCK/Isoloatin Level for READONLY database

Author
Message
anonymous2009
anonymous2009
SSC Journeyman
SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)

Group: General Forum Members
Points: 76 Visits: 175
Hello,

We have a sole readonly database which is updated monthly at night during maintenance window. The db has several stored procedures from simple to with medium complexity.
Certain stored procedures are slow And need advice on what could be done given the database is readonly.

The stored procedures do have Set NoCount On.
I'm looking at possible indexes that cold be added to tables.

Question 1:
But on another note I'm wondering if introducing Nolock in all sqls a good idea?

Question 2:
Also is there an alternative to putting no lock in each and every SQL in the database?

Question 3:
Would READ COMMITTED SNAPSHOT isolation level be an alternative for Nolock given the database is READONLY (database itself is not set to READONLY. The applications accessing the database will only read from it and will not right to it ever).


Thanks!
GilaMonster
GilaMonster
SSC Guru
SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)

Group: General Forum Members
Points: 87889 Visits: 45274
If the database is read only, you won't be seeing any blocking (because nothing can ever write to the tables), so there will be no gain from read uncommitted or snapshot isolation.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


anonymous2009
anonymous2009
SSC Journeyman
SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)SSC Journeyman (76 reputation)

Group: General Forum Members
Points: 76 Visits: 175
Thanks for your response.

The database I'm dealing with is not set to readonly. Application does only reads from it. We do occasional updates every month, but during that process we shut the application down.

Instead of making the db as readonly, what will be the performance implications between isolation levels READ UNCOMMITTED and READ COMMITTED SNAPSHOT isolation?
Which would be better for my case?

How complex is the process to set the database as READONLY? The reason I'm asking because, our db will be deleted every couple of months and the new database version will be restored.
So setting the db as READONLY after the restore will have to be repeated every single time the restore is done?
Thanks!
GilaMonster
GilaMonster
SSC Guru
SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)

Group: General Forum Members
Points: 87889 Visits: 45274
If you are not doing any data modifications, then you will not be experiencing blocking and therefore there's little point in changing or fiddling with the isolation level.

Identify the badly performing code, tune it.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86766 Visits: 41103
anonymous2009 (9/15/2012)
Thanks for your response.

The database I'm dealing with is not set to readonly. Application does only reads from it. We do occasional updates every month, but during that process we shut the application down.

Instead of making the db as readonly, what will be the performance implications between isolation levels READ UNCOMMITTED and READ COMMITTED SNAPSHOT isolation?
Which would be better for my case?

How complex is the process to set the database as READONLY? The reason I'm asking because, our db will be deleted every couple of months and the new database version will be restored.
So setting the db as READONLY after the restore will have to be repeated every single time the restore is done?
Thanks!


I don't believe any of that will help. The application is "read only" and offline while you're doing the updates to the database.


Certain stored procedures are slow And need advice on what could be done given the database is readonly.


Which stored procedures? The ones that the application uses? Is it always the same stored procedures that run slow?

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Nadrek
Nadrek
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1905 Visits: 2729
If your only currently known symptom is "some SQL statements are slow", then you need to start with the usual analysis steps even before you get to troubleshooting.

1) What is "slow"? Why? Did it used to be different? How long ago? What is a list of everything that changed over that time?
2) What is "fast"? Why? Is that even reasonable (i.e. a full table scan of 25TB of data in 0.05 seconds is not reasonable... no matter how much someone wants it)
3) What hardware are you on right now? Keep coming back to this to get more detail, down to the particular spindles and what shares each element, as you work through the other aspects, until it's "fast enough".
4) What wait states are growing fastest when it's "slow"? "fast"?
5) What SQL statements are involved? All? Some? What do they have in common? Time of day based?
6) What else happens when it's "slow"? When it's "fast"? On the database? On the instance? On the hardware? On the network? On the SAN? On the user's machine?


There's a lot to look at and a lot to learn - any one "quick fix", whatever it is, will only work if that addresses most to all of your current issue. You may have a different current issue, or more than one.

Alternately, free up some budget and hire one of the many experts available, some of whom post here.
TheSQLGuru
TheSQLGuru
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12554 Visits: 8555
1) set database to read only during normal opps. Set it to read/write during your monthly update cycle (when other access is disabled) and then back to read only when complete.

2) Get professional help to tune the problematic queries (and mentor you on how to do the same in the future).

Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
pooyan_pdm
pooyan_pdm
SSC-Enthusiastic
SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)

Group: General Forum Members
Points: 194 Visits: 422
By setting the DB to readonly no Shared-Lock is requested anymore so there 's a performance benefit in doing that.
and the syntax is so easy
ALTER DATABASE [DB] SET READ_ONLY

Pooyan
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search