Posts Tagged ‘Database’

Degrees of Parallelism

Tuesday, February 3rd, 2009

If you are expecting a deep, well researched, thorough explanation of degrees of parallelism and cost threshold for parallelism you have come to the wrong place.  I’m sorry.  Hit the back button and choose a different link.  O.K., now that I’m alone again, I can get into my issue.  I have a vendor application, which will remain nameless, that is having some problems.  I have noticed by watching activity monitor that this database really chews up CPU.  When this app is quiet, I see CPU in the teens.  When it starts running I see 50% with 70% spikes.  But what has caught my eye, using SSMS 2008, is how much this app self blocks.  I don’t know if that is a real term, but I like it.  What I am talking about is one SPID that spawns several threads with the same SPID and those threads start blocking other threads on the same SPID.  As soon as I start seeing this I see CPU start climbing.  I also see waiting process start to grow.  It doesn’t take too long until I hear my phone ring.  The vendor has told me I can kill off these processes without harming the application.  So I’ll kill a few of them and get CPU back down to 30% – 40% and everyone is happy.  So I start wondering.  If I can decrease the number of threads that run at one time, maybe I can decrease the blocking and resolve this issue.  I read a post of someone who changed max degrees of parallelism from 0 to 1 and his problem went away.  That made perfect since to me: every process can have one CPU at a time.  But that also bothered me.  Microsoft put parallelism into the product because it helps with performance.  Turning it off can’t possibly make things faster.  There has to be a balance.  Increase the threshold, lower the number of processors there has to be a sweat spot.  But how to measure it.  That is my problem.  HMMM……  There must be a objective way to measure the application speed and make changes, watch the CPU, and the application speed.

Speaking of SSMS 2008.  I really like the activity monitor.  This seems to really give a lot more information.  The data file I/O section sorted by response time is very interesting to watch and I’m sure I will be using it in discussions with my SAN team in the future.  I just wish I could figure out how to freeze the processes section.  The refresh gets a little annoying to me.  But all in all I really like it.

Well I’ll spend some more time on this tomorrow and maybe have some solutions to my problem with this application.  Wish me luck.

Developer can not create views

Wednesday, January 28th, 2009

I received a e-mail a few days ago from one of our developers informing me that he is unable to create views on one of our SQL Server 2005 databases.  He also told me he had another developer try and she also could not create views.  Interesting, I thought, so out to my favorite co-worker – Google.  My buddy Google quickly pointed me to this MSDN post.  This explained to me that when a user gains rights by Active Directory group membership they are not given a default schema.  Say what? Yes, that’s right, because multiple AD groups could have rights on a database, and a user could be a member of multiple AD groups it could get confusing.  So any statement that requires a schema will fail with some form of the following error message.

Property DefaultSchema is not available for Database ‘[<database>]‘. This property may not exist for this object, or may not be retrievable due to insufficient access rights.  (SQLEditors)

So the first solution to the problem I found was to create a login for the user on the database server, give him public rights to the database in question, then revoke connection rights to that user.  What a bunch of work, I’m much to lazy to do that kind of work on every database for every developer in our organization.  So I called upon another friend, I believe he has run into every possible SQL issue and lived to tell about it.  That, of course, is Denny Cherry.  He replied with a simple solution.  Have the developer prepend (I know, there are discussions about if this is a word or not.  But I like it so I’ll use it.  I have never really been bothered by that.  Originally there were no words and people started using them and they became words.  Maybe….) the schema. to the view name during the creation.  I love it, it let’s the developers resolve the problem.

One New Years Resolution Down….

Friday, January 16th, 2009

After being tagged to blog my Professional New Years Resolutions late last year, I made getting certified as my first one.  Today I bit the bullet and took the 70-431 test.  I took about an hour to complete the 35 trivia (multiple choice) and 12 simulations.  I was a little shocked when the screen displayed 1000/1000 for my score.  The family and I celebrated big time.  We went to Moe’s Southwest Grill and then went to the mall so the kid could use the Christmas money that was burning a hole in their pocket.  So I’m going to take the rest of the month off, then start studying for the next one.  Maybe the 70-432…

Finding databases that have changed to Simple Recovery Mode

Friday, January 2nd, 2009

As I am beginning our journey into SQL 2008, I am taking this time to go through all our scripts and try to resolve some of the issues I get alerted on that are due to how we do things.  One of the things we do is programatically list all the databases, determine which are prod, test, & system.  Then the Prod databases have xlog backups and the others do not.  Occasionally, some of our prod databases will change from Full Recovery Mode to Simple Recovery Mode.  How I find out about this is that the Xlog backup job will fail.  The first database that should have been in Full but was in Simple would fail the whole job and transaction logs would not be backed up.  Failing jobs is a horrible way to find out that a recovery mode changed.  So I re-wrote our backup job to query sys.databases and do xlog backups to any database in full recovery mode.  No more xlog failures for wrong setting.  Life is good.  But wait, what if a database does change modes how will I know?  Sure the xlogs of databases that are in full recovery mode backed up, but that may not be good enough.  So I sat back down and started wrote an new script.  This script looks at yesterday’s list of Simple Recovery Mode servers and compares it to Today’s list.  If there is a new database in Simple recovery mode it sends me an e-mail to investigate it.  If there is no change, it just ends.  Here’s the code.

declare @NewSimple int, @subject varchar(256)

select name into maintenance..backupsimple from sys.databases where recovery_model = 3

SELECT name into ##backupchange
FROM
(
SELECT name
FROM maintenance..backupsimple
EXCEPT
SELECT name
FROM maintenance..backupsimpleold
) tmp
GROUP BY name
HAVING COUNT(*) = 1
ORDER BY name

select @NewSimple = COUNT(name) from ##backupchange
if @NewSimple >0
BEGIN
select @subject = ‘New Simple Mode Databases on server ‘ + replace(@@servername, ‘\’, ‘_’)
exec msdb..sp_send_dbmail
@profile_name = ‘SQL Server’,
@recipients = ‘<My E-mail address>’,
@importance   = N’HIGH’,
@subject = @subject,
@body = ‘Please verify the following databases should be in Simple Recovery Mode.  They were not in Simple Recovery mode yesterday.  Remember to perform a full backup if you change the model to full recovery mode:’,
@query = ‘select name from ##backupchange’
END
drop table maintenance..backupsimpleold
select name into maintenance..backupsimpleold from maintenance..backupsimple
drop table maintenance..backupsimple
drop table ##backupchange

I have this running once a day for now.  Maybe in the future it will need to run more often.

Professional New Year’s Resolutions

Tuesday, December 30th, 2008

Well, I’ve been tagged.  SQLBatman has tagged me to post my New Years Resolutions.  I have so much room for professional development I’m not sure where to start.  So I’ll start with some pain points.  So here they are:

1.  Get Certified. I have been in the IT business for over 10 years and have not taken any certification exams since I was a NetWare 4.0 admin.  Since I think I’ll be hanging out in the database world for the foreseeable future, I think I should prove my skills.

2.  Learn to effectively use profiler. I hate how much time I spend setting up a trace because I really don’t know what I’m looking for I also need to increase my experience at reading traces to make correct resolutions to issues faster.

3.  Be able to resolve some of the basic, recuring Oracle issues I get paged with and must pass off to our Oracle DBAs. I share on-call with our Oracle & Sybase DBAs.  I feel so guilty to have to call them for any Oracle log I get.  One has been a DBA for 10 years and the other 30 years (going all the way back to our mainframe days) they can resolve out MSSQL logs most of the time without my assistance, I need to return the favor.

4.  Learn SQL Server Analysis Services. Judging from the keynotes at SQLPass, SSAS will have a much larger footprint during 2009.  I need to know how to troubleshoot and support it.

So it’s my turn to share the love.  I, like SQLBatman, do not know how has been blessed with this task.

You have been tagged:

Neil Watkins

Jimmy May

Susan Delaney

Michelle Ufford

Getdate() Formatting

Tuesday, December 30th, 2008

I get the occasional question from our Oracle DBAs on how do you do this in MSSQL.  Usually I have little to no idea, so I do what all new DBAs do:  Look it up.  Well, this situation came up today on how can I write a procedure that will query the table and give me all the enteries for today.  The column the date is stored in is varchar in this format 11/14/2008.  I found the answer is select convert(varchar,getdate(),101)  So I thought I’d add the sytle ID numbers for future reference.

Style ID

Style Type

0 or 100 mon dd yyyy hh:miAM (or PM)
101 mm/dd/yyyy
102 yyyy.mm.dd
103 dd/mm/yyyy
104 dd.mm.yyyy
105 dd-mm-yyyy
106 dd mon yyyy
107 Mon dd, yyyy
108 hh:mm:ss
9 or 109 mon dd yyyy hh:mi:ss:mmmAM (or PM)
110 mm-dd-yyyy
111 yyyy/mm/dd
112 yyyymmdd
13 or 113 dd mon yyyy hh:mm:ss:mmm(24h)
114 hh:mi:ss:mmm(24h)
20 or 120 yyyy-mm-dd hh:mi:ss(24h)
21 or 121 yyyy-mm-dd hh:mi:ss.mmm(24h)
126 yyyy-mm-dd Thh:mm:ss.mmm(no spaces)
130 dd mon yyyy hh:mi:ss:mmmAM
131 dd/mm/yyyy hh:mi:ss:mmmAM