BorderLayoutBoxedLayoutOpenLayoutMaximum textMedium textSmall text


Register
Tuesday, March 09, 2010
MyStreamMinimize
Print  

Entries for the 'SQL Server 2005' Category

June #SQLPASS DBA SIG Meeting

Posted by Jason Massie Click to IM Jason Massie on Tuesday, June 02, 2009 at 8:39 AM to SQL Server 2008, SQL Server 2005, syndicate
833 Views | 0 Comments | Article Rating

SQLSnakeEyes I am presenting that June DBA SIG. This will be the topic:

Highly Available SQL Server Upgrade Assault Tactics

In this debriefing, we will look at various methods to minimize downtime during major version upgrades. This will include upgrading from SQL Server 2000 to SQL Server 2005 and SQL 2008 as well as SQL Server 2005 to SQL Server 2008. We will cover key planning and testing skills that can cut substantial time off the upgrade and minimize problems after the upgrade. We will also cover the technologies that you can add to your arsenal when planning an HA upgrade assault. All hands on deck as we do battle against upgrade downtime.

The meeting will be June 24th at noon Eastern. More info can be found here soon. However, set an outlook reminder now. Is it set? No? Well, set it now!

email it! |   |   | 

SQL Server Gal is a Biker Chic

Posted by Jason Massie Click to IM Jason Massie on Tuesday, May 26, 2009 at 10:30 PM to SQL Server 2008, SQL Server 2005, Humor
944 Views | 1 Comments | Article Rating

SQLGal

 

I didn’t say it. :) However, I must say it is interesting prose. You can visit the site here and read up on her, Visual Studio Guy, Windows Master and the other members of “The Source Fource”. Might I add that Capt. Varchar made it to 2nd base but she won’t call him back.

Oh well, it is all her loss.

A keen motorbike enthusiast, SQL Server Gal spends her free time and energy looking after her beloved Harley Davidson, called Data Drive. She spends Sunday afternoons challenging the speed barrier and enjoying the natural beauty of the countryside. But with her feisty, alternative take on the world, SQL Server Gal is a biker chick with a difference. Her vast knowledge and language skills mean that she has an answer to every question. And despite her glitzy life as a member of the Source Fource, she still uses her extraordinary memory skills to help others realize their ambitions.

Read more.

email it! |   |   | 

SQL Backup Cleanups(or Did your Moneybags Make it to Tape?)

Posted by Jason Massie Click to IM Jason Massie on Thursday, May 21, 2009 at 12:13 PM to SQL Server 2008, SQL Server 2005, editorial, syndicate
1352 Views | 3 Comments | Article Rating

moneybags I have long hated maintenance plans. First was because of the cryptic error messages when they fail. However, DBAs before me clued me into the fact they clean up files whether or not they make it to tape. The cleanup process is oblivious to the tape backup. This is really important. It can be catastrophic for this to happen. How many days do you keep on disk? One, two, three, seven days? Do you manage the tape backup as well? What if you have to restore from tape longer than that but the windows\backup admin was out on vacation while the tape backup was failing? I submit to you that it is better to fill up the backup and log drives before you delete non-archived backups.

There are several ways you can guarantee backups make it to tape before you delete them. First, you could check the archive bit.

For example:

del /a-a *.trn *.bak *.dff

Of course, you may wish to do it from powershell, vbscript or xp_cmdshell so you can only delete files older than a certain date. You may want additional logic if you need to keep a weekly full, a nightly diff and 24 hours of tlogs ON DISK.

Most backup software also allows you to run a post job script where you could clean up backups. I can think of horrific scenarios where it would still delete the “money bags” so I would stick with the windows file system attribute. If there is a bug there, it will be SEV A and lot of people will run into it.

email it! |   |   | 

Connecting to SQL Server in Single User Mode

Posted by Jason Massie Click to IM Jason Massie on Monday, April 13, 2009 at 5:27 PM to SQL Server 2008, SQL Server 2005, syndicate
3130 Views | 2 Comments | Article Rating

Have you had to connect to SQL Server in single user mode but the application always beats you to it. No matter how fast you try! I have actually had to unplug nics and have smart hands do it. Well, there is a soon to be documented extension of –m.

Basically, you can specify an application like -m"sqlcmd". This means only a single instance of the SQLCMD application can connect. Just start SQL with -m"sqlcmd", unbreak what you just broke and the restart SQL normally. :) Nice, huh?

Keep in mind that there are ways around this so don’t use it for security.

email it! |   |   | 

Physical Database Layout

Posted by Jason Massie Click to IM Jason Massie on Friday, April 10, 2009 at 11:10 PM to SQL Server 2008, SQL Server 2005, syndicate
1344 Views | 0 Comments | Article Rating

Paul Randal has a survey on his blog that I would be interested in seeing as largest as sample as possible. I think this is important so I am going to post a link to you. Your vote counts. Yes, we can!

http://www.sqlskills.com/BLOGS/PAUL/post/Weekly-survey-does-size-really-matter-or-is-it-what-you-do-with-it.aspx

I come from the school of thought that unless you have an enterprise SAN that exceeds your IO requirements or you are intimately familiar with the IO patterns of your app, that you should use one disk group for burstable performance and possibly a second disk group for backups.

email it! |   |   | 

Mixed Workloads Part 3

Posted by Jason Massie Click to IM Jason Massie on Tuesday, March 31, 2009 at 8:17 AM to SQL Server 2008, SQL Server 2005, SQL performance tuning, tsql, Indexes, consolidation, editorial, syndicate
1585 Views | 0 Comments | Article Rating

In part 1, I talk about what I consider feeble attempts at implementing a reporting server through log shipping, mirroring\snapshots and, to a lesser extent, replication. Unless you invest in a real ETL solution, I argued that it is better to run a mixed workload. I talked about the architectural advantages of running mixed workloads in part 2. In a nutshell, doubling the hardware and cutting the data in half.

In this final post, we will talk about new features in SQL Server 2008 and some features that have been around a while that can help with mixed workloads.There are also some bad practices that could be the right answer that we won’t  talk about but let us mention triggers, table valued functions, 20 table outer joins, some correlated subqueries and table variables. These are options but usually not good ones. In the right circumstances, they could be right like an end of year report.

Here are the main tools in your arsenal:

  • Resource governor
  • Covering filtered Indexes
  • Indexed views
  • Partitioning + data compression
  • Persisted computed columns
  • Archiving on the same server
  • After hours denormalization(indexes views with deferred updates)

Resource Governor

Chances are you do not want to limit throughput of your OLTP queries. The resource governor does not do a good job with these queries anyway because their duration is usually so short. However, let’s say you have reports that run by executives. You can put them in a workload group that gives them as much resources as possible without affecting OLTP traffic. You may also have a less important group of reports from the marketing or sales teams that you can limit further. One caveat to the resource governor is it cannot limit, disk IO so if that is your bottleneck, this will not help much.

Covering Filtered indexes

Filtered indexes are a great new feature in SQL Server 2008. When optimizing for reporting queries on your OLTP system, you are probably going to be touching a lot of rows so covering the query is important. For example, the order fulfillment team works off a report of unfulfilled orders that pulls in order data, customer data, shipping data etc. In this case, you would add covering filtering indexes on each of those tables. The filtered indexes reduce write overhead on your OLTP writes and reduces read overhead of your reporting.

Indexed Views

Indexed views take filtered indexed view a step further. You can create indexes on multiple tables. Think of it as denormalization alongside your OLTP optimized schema. In the previous order fulfillment example, we can basically persist that report and have it updated in real time. There is more overhead to your OLTP transactions so weigh the pro’s and con’s. Test if possible.Unfortunately, you cannot defer changes to your indexed views but I believe there is a feature request for this on Connect and I will tell you about a workaround shortly.

Partitioning and Compression

This is the dynamic duo when mixing workloads. Unfortunately, the nitty gritty details would require their own post. For example, one mixed workload may benefit from compression on the hottest partition while the older data should be uncompressed. However, another workload may benefit from the opposite. The key here is really understanding your workload, data and hardware limitations. Most importantly, plan then TEST, TEST, TEST! Once you partition, you loose online operations so if you do it wrong, you are stuck.

 Persisted Computed Columns

This is an easy one. It is a simple trade off. Writes take a little more CPU and space in exchange for reduced CPU time when you report. Take your orders table, for example. You could calculate and save shipping costs when you insert the rows. If it adds a few milliseconds to the insert but shaves seconds off the hourly open orders report that the execs are looking at, it may be an easy decision.

Archival

This might not always be possible depending on your data. It may not be necessary if you have finely tuned indexes. However, it could make a night and day difference. If you need the data, UNION ALL’ing the production table with the archive table has little overhead. I do suggest you keep the archive database on the same server unless it will rarely be accessed. Trying to do this with linked servers is bad.

After hours denormalization

This is basically precreating reports during off hours. Think of it as indexed view with deferred updates. You can UNION with the OLTP tables if you need realtime data in your report. In an ideal world, touching less rows in the OLTP table and then UNIONing with the denormalized data will result in the best of both worlds if you need real time data.

The final word

As the concurrency and size of data scales, both a pseudo reporting database and a mixed work load scenario will not meet business requirements. A business requirement of real time data may dictate a mixed workload. There may be plenty of workloads where scaling out and scaling up both meet performance demands. I just wanted to play devil’s advocate and  let you know there is another option when planning reporting.

email it! |   |   | 

Mixed Workloads Part 1

Posted by Jason Massie Click to IM Jason Massie on Saturday, March 21, 2009 at 11:54 AM to SQL Server 2008, SQL Server 2005, editorial, syndicate
1175 Views | 0 Comments | Article Rating

I am presenting at the Ft. Worth SQL Server Users Group in April. Details forthcoming but it is basically going to be on running mixed workloads(OLTP and DSS) on the same server. This is part one of what I will be pulling into the presentation.

What is NOT a Reporting Server

Log Shipping

A log shipped copy is not a reporting database. It is the same database that should be optimized for OLTP. You have no control to add supporting indexes. No denormalization. No persisted computed columns. No indexed views. Disconnects can happen midquery. More hardware. However, this is often the easiest solution,

Database Mirroring with Snapshots

This configuration suffers all the limitations of logshipping. However, you must run Enterprise Edition. You can get around the disconnects with creative coding.

Nightly Backups\Restore

Just like log shipping but the data is behind which may be ok based on business requirements. You can get around the limitations of logshiping like indexing etc. However, not practical for VLDB.

Snapshot Replication

This is ok for smaller databases plus you can filter tables and columns if they are not needed. You can get around some of the limitations of log shipping and mirroring but data is stale.

Others

Offline the database, robocopy, attach. DTS\SSIS the whole db. SAN Replication. Transactions replication with no reporting modifications.

The problem

You double your hardware and storage with no real reporting gains in most scenarios. This might be acceptable if the reporting environment duals as DR. However, there are better solutions.

What is next?

Moving forward, we will talk about doubling the hardware on OTLP and using SQL 2008 feature to run reporting and OLTP on the same server.

email it! |   |   | 

Another Overlooked Windows Setting for the DBA

Posted by Jason Massie Click to IM Jason Massie on Friday, March 20, 2009 at 5:33 PM to SQL Server 2008, SQL Server 2005, SQL performance tuning, hardware, syndicate
1519 Views | 1 Comments | Article Rating

*Warning* Only use if your array controller has a battery backed cache. *Warning*

The settings are “Enable write caching on the disk” and “Enable advanced performance”. You can access these through device manager on the properties of the disk. These settings mostly apply to direct attached storage and are unavailable for most enterprise SAN lun’s that I have seen.

While we are at it, if your RAID controller cache has a read\write ratio, it is a good idea to set it to 0% read\100% write as long as you do not have a memory bottleneck. SQL uses RAM as its read buffer.

So is this a silver bullet for performance? Definitely not especially if you are not hitting a disk write bottleneck. However, every little bit helps and if it knocks 5-10% off of your 3 hour long full backup to disk, that is a win!

Happy Friday!

email it! |   |   | 

An Often Overlooked Windows Setting for the DBA

Posted by Jason Massie Click to IM Jason Massie on Thursday, March 19, 2009 at 9:07 AM to SQL Server 2008, SQL Server 2005, Windows Server 2008, SQL performance tuning, memory bottleneck, syndicate
6509 Views | 8 Comments | Article Rating

The default setting is the wrong setting for SQL Server. However, unless this has caused you a problem or you are thorough to point of OCD, this may not be set on your server.

Unless you are fighting a memory bottleneck, it probably won’t affect you too much but it is hard to give SQL too much memory.

The setting is “Maximize Data Throughput for Network Applications” and on by default. It sounds like a good thing. To the contrary, here is documentation from MSDN.

http://msdn.microsoft.com/en-us/library/ms178067.aspx

Maximize Data Throughput for Network Applications

To optimize system memory use for SQL Server, you should limit the amount of memory that is used by the system for file caching. To limit the file system cache, make sure that Maximize data throughput for file sharing is not selected. You can specify the smallest file system cache by selecting Minimize memory used or Balance.

To check the current setting on your operating system

1. Click Start, then click Control Panel, double-click Network Connections, and then double-click Local Area Connection.

2. On the General tab, click Properties, select File and Printer Sharing Microsoft Networks, and then click Properties.

3. If Maximize data throughput for network applications is selected, choose any other option, click OK, and then close the rest of the dialog boxes.

Happy Tweaking.

email it! |   |   | 

Linked Server Provider Options

Posted by Jason Massie Click to IM Jason Massie on Tuesday, March 17, 2009 at 1:40 PM to SQL Server 2008, SQL Server 2005, syndicate
2015 Views | 1 Comments | Article Rating

Some of these are confusing so I thought I would write a blog on it. The post only refers to the SQLOLEDB and SQLNCLI providers.

Here are your options:

image

So In layman’s, let’s talk about each:

Dynamic Parameters: If you have a lot of adhoc queries against linked servers this may be a good option to turn on along with forced parameterization. Search your proc cache for queries containing the linked server name with single use counts.

Nested Queries: I would say that is depended on the business requirements.

Level Zero Only: Leave default for SQL Server

Allow InProcess: This is on by default with the native client provider but off by default with the SQLOLEDB provider. I might try changing to in process with OLEDB especially if context switches were high and % kernel time was high.

Non Transacted Updates: I would really use caution with this. It is like a NOLOCK hint. It may be ok for the app but unintended consequences could happen. Besides, maintaining the transaction is probably a small part of the duration when you are hitting the network.

IndexAsAccessPath: I make the mistake of turning this on once. It sounds like a good thing. To quote MSDN, “If True, the OLE DB provider indexes are used to fetch data. If False (default), the SQL Server indexes are used to fetch data.” Leave it false!

Disable Adhoc Access: This depends. I would normal setup a linked server for administrative tasks and a lot of work would be adhoc but the linked server would be locked down.

Supports “Like” operator: This also depends on business requirements but you are probably going to get crappy performance.'

Hold up cowboy

I would not run out and start changing stuff. Number one, avoid distributed queries in OLTP apps to begin with. Number Two, make one change at a time. Number three, if you change something and performance degrades you will probably see remote scan vs. remote queries in query plans.

email it! |   |   | 

Lessons Learned with SQL Server on VMWare

Posted by Jason Massie Click to IM Jason Massie on Thursday, February 19, 2009 at 8:11 AM to SQL Server 2008, SQL Server 2005
3899 Views | 3 Comments | Article Rating

This past weekend I asked the community(or at least my twitter feed) what they thought about virtualized database servers. Lots of people use it in Dev\Test\QA. Some in prod. Some thought it was pointless. Before I go over my lessons learned, let me address the “pointless” point.

It could be argued that it adds another unneeded level since you could do this with instances. For that matter, you can use one instance and permissions. This is true. If you are consolidating just a few instances, the cost and overhead probably doesn’t justify virtualization. However, there are other benefits like VMotion or adding capacity horizontally. You can’t easily move two instances off an over utilized box. With ESX, you can do this online while transactions are in flight. Added redundancy is also a benefit.

So here are my lessons learned:

Beware of CPU bound workloads

Most database workloads are IO bound even if it is logical IO’s. However, if your database is really small but you do lot of complex calculations, lots of business logic or string manipulations etc, your performance may suffer more than you would expect.

Use x64

This is just a vendor recommendation that suggests a 10% gain.

Don’t trust the CPU counters

Another thing I learned from the whitepaper. The CPU ready counter in Virtual Center is very useful.

Set a memory reservation

I would at least reserve half of the memory given to the guest especially if the host is busy. ESX has a balloon driver that will take memory from guests if it needs it and it thinks the guest is idle. This usually is not good for database servers.

The Microsoft Windows Server 2003 Scalable Networking Pack is evil

This is enabled by default with Windows Server 2003 sp2 and it doesn’t play well with SQL Server, VM’s and especially SQL Server on VM’s. See this post.

You have to sector align TWICE

First you have to sector align the vmfs and then at the OS level. Here is VMWare recommendations. I agree with Kendal’s recent finding of 128k offsets and 64k NT allocation unit based on my own testing.

If you have a lot of SQL VM’s on a host, see if EE makes sense

With Enterprise Edition, you only have to license the host. If you use standard edition, you must license each guest. If no EE features are needed, “lock pages in memory” alone, may be enough. In addition to other problems it solves, you can enable large page support.

Bad code usually runs worse on a VM

Man, the weather has been nice. How about them cowboys!

 

Anyway, do you have any lessons learned running SQL on VMWare..

email it! |   |   | 

Things you Know Now…

Posted by Jason Massie Click to IM Jason Massie on Tuesday, February 10, 2009 at 8:45 AM to SQL Server 2008, SQL Server 2005, Professional Development
1506 Views | 7 Comments | Article Rating

There is a new meme started by Mike Walsh (Twitter, blog). He tagged Brent Ozar(RSS, Twitter) who tagged me amongst other.

Here is the the basis of the meme to quote Mike.

When I wrote about empirical evidence and learning through trying (instead of asking only), I got thinking about things I wish I knew when I was a Junior DBA that I know now.

So here is what I know now that I wish I knew then(and usually learned the hard way).

Microsoft Project is your friend.

I have written about this before but it is worth it to revisit. I started out making big production changes to mission critical systems with nothing but a task list in my head. I evolved to notepad and then excel. My success % improved with each jump. Now, I can floor my boss and customers with downtime estimates accurate the minute. On top of that, I can establish doable timelines and get more resources if my time line does meet expectations.

You can be your worst enemy.

Ego can make a brilliant employee a liability. It manifests is several ways( at least for me).

  • Jump on the new groups sporting all your brand new certs in your sig trying to “help”. However based on attitude, it is clear you are there for the wrong reasons usually attention.
  • Bogarting knowledge. So you know something someone else does not, teach them instead of holding it over them. Help out he jr guy. He may be your boss someday.
  • Ego can keep you from asking for help when you are clearly in over your head. I still struggle with this one.

Life is so much better when you are modest rather than smug.

If the hole is round, a square peg may not be the best fit.

I have officially become platform agnostic. SQL Server will always be my first love and what I am best at but there are other products out there. Not that I know everything there is about SQL but I don’t learn 10 new things about it everyday like I used to. As a n00b, I learn 30 new things a day about MySQL\Oracle. There are valid reasons to go MySQL or Oracle over SQL Server. That is just the way it is. Imagine rewriting the DAL layer for Wiki or Wordpress just because you had to run it on SQL Server. If you drink that much koolaid, more power to you. I think knowing the features and limitations of other platforms helps me as a SQL Server DBA as well.

The GUI is not your friend.

I used to be an enterprise manager DBA. When I learned how to admin from TSQL, that is were the Senior DBA level skills came in. I still use the GUI if it a click or two vs. several lines of code but I know how to write it and, if need be, automate it. If you can’t, learn.

Know X as good or better than the subject matter experts

Where X is technology that interacts with the database: The OS, hardware, SAN, network, and application code. Of course, this is not always feasible. I have never jumped on a switch to prove it is not a SQL Server problem but I have gotten pretty close. Once when all fingers pointed at SQL Server, I had them check the switch for errors and sure enough the firewall was set 100/half duplex. If nothing else, learn the hardware and OS inside and out.

Next Victims

Jonathan Kehayias(RSS, Twitter)

Jason Strate(RSS, Twitter)

Rob Boek(RSS, Twitter)

email it! |   |   | 

Key Lookup Threshold

Posted by Jason Massie Click to IM Jason Massie on Thursday, February 05, 2009 at 8:05 AM to SQL Server 2008, SQL Server 2005, query optimizer, SQL performance tuning, Indexes
2273 Views | 1 Comments | Article Rating

Gail talks about bookmark lookups…. err.. key lookups in this post. So are they good or bad? Well, like many things in SQL, it depends. The main factor is the number of rows returned. A few rows are fine but the cost rises sharply with larger result sets. There comes a point where the threshold is crossed and a scan is more efficient. This is because a scan leverages sequential IO while a lookup does random IO.

Here are the results of the code at the end of the post.

RowsIO 
Scan422 
1 row4 
5 rows12 
10 rows22 
25 rows52 
50 rows114 
100 rows217 
250 Rows526<--Threshold
500 Rows1043 
1000 Rows4141 

 

As you can see, at 250 rows, we have crossed the threshold and it is cheaper do a scan. If you are passing in a literal, the optimizer can detect this and switch to a scan. If it is a stored proc or parameterized SQL, a plan is cached the first time it is run. Problems happen when the result size greatly varies depending on the parameter. There are ways around this all with their pro’s and con’s. Here are some:

  • A covering index.
  • A statement level recompile hint
  • Plan guides and hints

Here is the sample code that can repro these numbers on SQL Server 2008.

CREATE TABLE #temp
(
id INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
c1 CHAR(1000) DEFAULT( 'blah'),
c2 INT
)
INSERT INTO #temp(c2)
VALUES
(1)
GO 
INSERT INTO #temp(c2)
VALUES
(5)
GO 5
INSERT INTO #temp(c2)
VALUES
(10)
GO 10
INSERT INTO #temp(c2)
VALUES
(25)
GO 25
INSERT INTO #temp(c2)
VALUES
(50)
GO 50
INSERT INTO #temp(c2)
VALUES
(100)
GO 100
INSERT INTO #temp(c2)
VALUES
(250)
GO 250
INSERT INTO #temp(c2)
VALUES
(500)
GO 500
INSERT INTO #temp(c2)
VALUES
(1000)
GO 1000
INSERT INTO #temp(c2)
VALUES
(1000)
GO 1000

CREATE INDEX ix ON #temp(c2)

--The baseline
SET STATISTICS io ON
SELECT
*
FROM #temp WITH (INDEX=1)
WHERE c2 = 1

--1 row returned
SELECT *
FROM #temp
WHERE c2 = 1

--5 rows returned
SELECT *
FROM #temp
WHERE c2 = 5

--10 rows returned
SELECT *
FROM #temp
WHERE c2 = 10

--25 rows returned
SELECT *
FROM #temp
WHERE c2 = 25

--50 rows returned
SELECT *
FROM #temp
WHERE c2 = 50

--100 rows returned
SELECT *
FROM #temp
WHERE c2 = 100

--250 rows returned
--Must begin using hints because the optimizer can tell that a scan is better
SELECT *
FROM #temp WITH (INDEX=ix, forceseek)
WHERE c2 = 250

--1000 rows returned
--Must begin using hints because the optimizer can tell that a scan is better
SELECT *
FROM #temp WITH (INDEX=ix, forceseek)
WHERE c2 = 1000

email it! |   |   | 

MySQL Cheatsheet for SQL DBAs

Posted by Jason Massie Click to IM Jason Massie on Monday, February 02, 2009 at 9:09 AM to SQL Server 2008, SQL Server 2005, tsql
1961 Views | 2 Comments | Article Rating

SHOW VARIABLES – This is like sp_configure or sys.configurations

SHOW STATUS – This like sys.dm_os_%. Basically, all runtime counters for the database engine components.

SHOW PROCESSLIST – This is like sp_who2

SHOW TABLE STATUS – This is like sp_help

These can be filtered like this: SHOW VARIABLES LIKE ‘%innodb%’

Those are the big ones. The full list can be found here.

email it! |   |   | 

The Death of JOIN

Posted by Jason Massie Click to IM Jason Massie on Saturday, January 31, 2009 at 11:49 PM to SQL Server 2008, SQL Shorts, SQL Server 2005, azure, The Cloud, SQL Data Services, editorial
1907 Views | 4 Comments | Article Rating

The core of a relational database is normalization. The reduction of data duplication is what it is all about. Less data means less IO. SDS removes database design from the equation. This is why sparse columns and filtered indexes where implemented in SQL Server 2008. Here are a few posts on how this is handled in SDS.

The End of of JOINs?

The End of JOINs Part 2?

Yah yah, it doesn’t apply to your job, business, sector. Adam may call me out on FUD again. I hope it is true since this is hopeware so far.

However, I want to point out one company who have found a cloud non-relational database to meet their business requirements. They state their limitations and it makes sense as to why they took this route. If you are not up to speed, Simpledb is Amazon’s cloud db. Big table is Google’s cloud db. You are here because you already know about MSFT.

Glue chooses  SimpleDB.

This is what we need to keep an eye on.

email it! |   |   | 

Capt. Varchar(MAX) and the Pagelatch Posse Vol. 18

Posted by Jason Massie Click to IM Jason Massie on Friday, January 30, 2009 at 11:44 AM to SQL Server 2008, SQL Server 2005, Humor, Captain Varchar(MAX)
1418 Views | 4 Comments | Article Rating

The Senior DBA

TheSRDBA

I am astounded by how often I see a problem that I know nothing about but fix it after finding the answer in a search. I get more high fives for being a good search engine user than a good DBA. On the flipside, I learned this by asking dumb questions and getting sent back a google search link.

The comic was adapted from OfficeOffline.

email it! |   |   | 

Need Some More Sample Databases?

Posted by Jason Massie Click to IM Jason Massie on Sunday, January 25, 2009 at 11:22 AM to SQL Server 2008, SQL Server 2005, tsql
1799 Views | 2 Comments | Article Rating

Microsoft has 10 “Express Database Schemas” that I ran across and I thought I would pass along. I am always on the look out for sample databases. Northwind will always have a special place in my heart like the girlfriend that cheated on me with my best friend. AdventureWorks is cool but the fact that every single feature in SQL Server 2008 is crammed into it makes it klunky.  Since these are designed for different types of applications, it might be a good idea to drop these in your toolbox.

These are on the SQL Server Express page. Of course, there is no reason that these cannot be run on the full version of SQL.

Click here for any or all of them:

It appears they were designed by Barry Williams so credit is due where it is deserved.

About the Author

Barry Williams, founder and Principal Consultant with www.DatabaseAnswers.org, has been working with SQL Server since the mid-90's. Barry works as an independent consultant, trainer and writer and is a popular speaker on Enterprise Data Management at major Conferences. He can be reached at info@barryw.org.

email it! |   |   | 

All of my SQL RSS Feeds

Posted by Jason Massie Click to IM Jason Massie on Saturday, January 24, 2009 at 12:28 PM to SQL Server 2008, SQL Server 2005, social networking
1591 Views | 0 Comments | Article Rating

To follow Rob Boek’s lead, I have publically shared all of my google reader SQL subscriptions(RSS) in addition to my shared items(RSS).

Here are the SQL feeds I currently read. Post your RSS link if I am missing out!

email it! |   |   | 

Is 80/20 a 90’s Estimate?

Posted by Jason Massie Click to IM Jason Massie on Friday, January 23, 2009 at 3:08 PM to SQL Shorts, SQL Server 2005, Indexes, editorial
1760 Views | 15 Comments | Article Rating

It has often been said that even the most write intensive OLTP databases have an average of 80% reads and 20% writes. I am thinking interactivity has increased in applications because technology has allowed it to get more write intensive but I am just guessing.

Run this on your OLTP Crown Jewels and post the results. While not very scientific, it will give us some anecdotal data. The query could also be useful when sizing new hardware.

I came up with 97/3, 74/26 and 60/40 on three high volume databases.


 

--This query has minimal impact.

--Looks at index metadata to determine read\write ratio since the last restart of the instance.
SELECT  
CAST(SUM(user_seeks+user_scans+user_lookups) AS decimal)/CAST(SUM(user_updates)+SUM(user_seeks+user_scans+user_lookups) AS decimal)
AS ReadPercent
, CAST(SUM(user_updates) AS decimal)/CAST(SUM(user_updates) + SUM(user_seeks + user_scans + user_lookups) AS decimal
AS WriteRatio
FROM sys.dm_db_index_usage_stats


Post your results!

email it! |   |   | 

Updated Unused Index Query

Posted by Jason Massie Click to IM Jason Massie on Tuesday, January 13, 2009 at 5:41 PM to SQL Server 2008, SQL Server 2005, SQL performance tuning, tsql, Indexes
2580 Views | 4 Comments | Article Rating

I have cleaned up and updated my unused index query. It returns a list of indexes ordered by ascending reads. If the instance has been up for a long time, it is probably safe to drop indexes with zero or close to zero reads. If the reads are low and the writes are high, this may help improve your transactions per second count. Otherwise, you are just cleaning up unused space. Use caution though. A missing index is worse than an unused index.

SELECT objectname=OBJECT_NAME(s.OBJECT_ID)
,
indexname=i.name
, i.index_id  
, reads=user_seeks + user_scans + user_lookups  
, writes user_updates  
, p.rows
FROM sys.dm_db_index_usage_stats s JOIN sys.indexes i 
ON i.index_id = s.index_id AND s.OBJECT_ID = i.OBJECT_ID  
JOIN sys.partitions p ON p.index_id = s.index_id AND s.OBJECT_ID = p.OBJECT_ID
WHERE OBJECTPROPERTY(s.OBJECT_ID,'IsUserTable') = 1  
AND s.database_id = DB_ID()  
AND
i.type_desc = 'nonclustered'
AND i.is_primary_key = 0
AND i.is_unique_constraint = 0
AND p.rows > 10000
ORDER BY reads, rows DESC

I will also be putting this query up at the SSP WIKI.

email it! |   |   | 

Finding Index Scans due to Implicit Conversions

Posted by Jason Massie Click to IM Jason Massie on Monday, January 12, 2009 at 7:00 PM to SQL Server 2008, SQL Server 2005, query optimizer, SQL performance tuning, tsql, Indexes, Procedure Cache, DMVs
2452 Views | 8 Comments | Article Rating

It is fairly widely known that implicit conversions of data types can cause scans. However, you may not be able to control what goes in your database, you may have inherited an app and we just are not perfect.

On top of that some can be tricky. For example, did you know that scope_identity and @@identity both return numeric data types. An AVG of a SMALLINT column returns an INT.

Here is a simple repro which the same query does an index scan instead of an index seek

CREATE TABLE t1
(
id INT IDENTITY(1,1) PRIMARY KEY CLUSTERED
, c1 VARCHAR(100)
)

GO

INSERT INTO t1(c1)
SELECT 1
GO 10000

INSERT INTO t1(c1)
SELECT 0
GO 10

CREATE INDEX ix ON t1 (c1)

CREATE PROC p1
@blah NVARCHAR(100)
AS
SELECT
id FROM t1
WHERE c1 = @blah

EXEC p1 N'0'

CREATE PROC p2
@blah VARCHAR(100)
AS
SELECT
id FROM t1
WHERE c1 = @blah

EXEC p2 '0'

DROP TABLE t1
DROP PROC p1
DROP PROC p2

 

I found a sample query from Umachandar Jayachandran and made some mod’s to it. It basically scans your procedure cache for index scans containing implicit conversions.

I have posted it at the SQLServerPedia Wiki here. It is the 2nd query listed.

Note: Implicit conversions may not always result in a scan.

email it! |   |   | 

SQL Server on Server Core

Posted by Jason Massie Click to IM Jason Massie on Friday, January 09, 2009 at 8:45 AM to SQL Server 2008, SQL Server 2005, Windows Server 2008
1975 Views | 3 Comments | Article Rating

 

Window Server 2008 R2 Server Core, that is. When this product went public beta yesterday, I scanned the feature list to see if were any new and cool features for the DBA. Nothing specific as far as I could see. It is x64 only and does support live migration which is equivalent to vmotion on VMWare. Cool but neither are necessarily SQL related.

In case you have not heard about Server Core. It is a stripped down version of Windows Server with no GUI. You basically log into a cmd prompt or administer remotely.

I just read that the .Net Framework is installed on Windows 2008 Server R2 Server Core Edition at Andrew Fryer’s Blog. This means SQL Server can be installed.

To quote Andrew, here are the benefits of SQL Server on Server Core :

  • more grunt for SQL Server in terms of memory and CPU
  • more security as there’s less attack surface
  • less downtime to patch the OS as there’s less to patch.

There is just one problem. Is it still Windows if there are no… umm… Windows?

More details on Windows Server 2008 r2 can be found in the reviewers guide.

email it! |   |   | 

Best SQL Server Blog Posts of 2008

Posted by Jason Massie Click to IM Jason Massie on Monday, December 29, 2008 at 8:03 AM to SQL Server 2008, SQL Server 2005, social networking
1608 Views | 2 Comments | Article Rating

I was going to try to go through my google reader shared items from this year and try to come up a list to end all lists. However, who am I to decide? On top of that, narrowing it down to a top 25 favorites was going to be a enormous task given the huge growth in quality SQL bloggers this year.

However, instead of giving you a list, I will give you a tool to find good SQL blog posts based on the collective conscience on the internet. Hopefully, you will see the value and join in making this tool better.

Popular Posts on “SQL Server”(RSS) from RSSMeme.

Behind the scenes in a nut shell

Blog software syndicates via RSS. Readers subscribe in google reader or their favorite reader but only google reader applies here. When a user in google reader finds a post interesting, he\she can share it. All of the shares are indexed by RSSMeme. The idea being is a human actually recommends the post. More shares the better. Sure, there are also sites like Digg and Dotnetkicks but the down sides to those make them less appealing to me.

A side effect

Using this link you can find recently shared items containing “SQL Server”. This can help you find new interesting feeds. You can also use it to find breaking new on SQL Server or whatever tickles your fancy. However, it may not be quite as real time as twitter.

Start sharing

So if you use google reader and don’t use the share functionality, start! And maybe, you too can be part of the Internet SQL Mafia ©. Westside.

Top Sharers

P.S. Congrats to the Detroit Lions for their perfect season.

email it! |   |   | 

TokenAndPermUserStore and a New Timer in SP3

Posted by Jason Massie Click to IM Jason Massie on Tuesday, December 16, 2008 at 6:48 PM to bugfix, SQL Server 2005
908 Views | 0 Comments | Article Rating

TokenAndPermUserStore cache bloat has been a problem for quite a few of my customers. It is hard to diagnose unless you have run across it before. The queries are just slow without a hardware bottleneck. There were enhancements in sp2, post sp2 hotfixes and trace flags to help out. To be fair to MSFT, most of the time, the root cause was bad plan reuse.

In SQL Server 2008, this memory clerk is configurable with sp_configure. Yay! However, in SQL Server 2005 SP3 you have a few new options detailed in this KB.

This is also one other noteworthy enhancement in SQL Server 2005 SP3

Note In SQL Server 2005 Service Pack 3 and in later service packs, the processor time stamp is not used. These versions of SQL Server 2005 use a more reliable timer that has a maximum precision of 1 millisecond.

The full article can be found here.

Edit: Bob Dorr has posted a more in depth explanation of the time change here.

email it! |   |   | 

Good SQL Blogs from around the Tubes.

Posted by Jason Massie Click to IM Jason Massie on Monday, December 15, 2008 at 8:35 AM to SQL Server 2008, SQL Server 2005
1207 Views | 6 Comments | Article Rating

This is my 2nd installment of cool new(at least to me) sql blogs. I am trying to focus on ones that have good content and may not being getting enough exposure(by my guess). Not that I can slashdot your blog or anything but links are good.

If you don’t end up here, it could be for several reasons:

  1. You blog is part of a large established aggregations like SQLBlog, SQLBlogcast, SQLTeam or SQLServerCentral.
  2. Your blog is an MSDN blog. I suggest you check this periodically.
  3. Your site is already high profile with lots links etc..
  4. I might not know about your site. Let me know.
  5. Most of your posts are not tsql or database engine related
  6. Yer mamma dresses you funny.

In no particular order:

1. Jim McLeod (WWW, RSS)

Recent highlight: Cluster Won’t Start Due to Incorrect Startup Parameters

2. Joe Sack (WWW, RSS) – Not new to me but a good one.

Recent highlight: Windows Server 2008 - How to Move the Quorum Disk Group

3. The Database Whisperer (WWW, RSS)

Recent highlight: Adding a Check Constraint to a View

4. Chris Shaw (WWW, RSS)

Recent highlight: SQL Quiz Part 2

5. Aaron Lowe (WWW, RSS)

Recent highlight: SQL Quiz: Toughest Challenge

6. Deepak - (WWW, RSS)

Recent highlight: SQL Server 2005 Default Trace

7. SQL in the Wild (WWW, RSS) Not new but you should be reading

Recent highlight: When is a critical IO error not a critical IO error?

8. SQL Ninja (WWW, RSS)

Recent highlight: Ongoing Education for the Terminally Lazy/Busy

9. You Want Fries with that? (WWW, RSS)

Recent highlight: SQL PASS Community Summit 2008

10. Glen Berry - (WWW, RSS)

Recent highlight - Excellent Results With SQL Server Native 2008 Backup Compression

email it! |   |   | 

My Blogroll is Jacked

Posted by Jason Massie Click to IM Jason Massie on Sunday, December 14, 2008 at 12:41 AM to SQL Server 2008, SQL Server 2005, social networking
823 Views | 1 Comments | Article Rating

I tried to create cool web 2.0 blog roll. It worked for a while but it is hosed.. It would take me too much time to recreate it. Not to mention blogs come and go so I am going to do three things.

  • Share from google reader interesting(to me) posts. These will show up in my friendfeed widget on the left. You can also subscribe to my shared items here.
  • Friend me on Facebook because they show up there too.
  • I am going to do a monthly post on new SQL blogs that I have found that are not getting a lot of exposure but have great content.

So post interesting things and you get  a link from me in several place. Woohoo. Yah, big deal, right? If I am missing you, let me know. The amount of good SQL blogs is growing exponentially and it is hard to keep up.

 

NOTE: IF YOU ARE ONLY POSTING AN RSS SUMMARY, I AM PROBABLY NOT READING YOUR BLOG!!!11WON

email it! |   |   | 

TCP Chimney Offload

Posted by Jason Massie Click to IM Jason Massie on Friday, December 12, 2008 at 12:23 AM to SQL Server 2008, bugfix, SQL Server 2005
3494 Views | 1 Comments | Article Rating

Here is a Windows setting that often doesn’t play well with SQL Server. There is not much info out there so I thought I would blog about it.

There are three sets of problems that I have run into that can come from it:

1. Network disconnects. It manifests at the client with these errors: Reference kb945977.

Error message 1
[Microsoft][ODBC SQL Server Driver][DBNETLIB] General Network error. Check your network documentation


Error message 2
ERROR [08S01] [Microsoft][SQL Native Client]Communication link failure


Error message 3
System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

Do any of those ring a bell? :)

2. High NonPaged pool usage with some NIC’s. Reference kb918483. This manifests with this error message.

A significant part of sql server process memory has been paged out. This may result in a performance degradation.

3. I suspect that a mysterious periodic cluster failover was caused by this. I cannot prove it though.

To disable this setting, run Netsh int ip set chimney DISABLED and reboot. You should do this at the client and SQL Server if you have problem 1. With problem #2 when you are on SQL Server standard edition, you might as well try it because if it doesn’t fix it you only have a few other options. Chances are that the only fix is an upgrade to Enterprise Edition.

There might be a good reason to leave it enabled in some situations but I am not sure what they are. It has caused me enough problems to turn it off by default.

 

Edit: Doh, Sara Henwood wrote a similar but better post on this issue. I wish I would have saved it to gray matter back when it came out.

email it! |   |   | 

New\Newish SQL Blogs(at least to me)

Posted by Jason Massie Click to IM Jason Massie on Sunday, November 16, 2008 at 8:27 PM to SQL Server 2008, SQL Server 2005
764 Views | 4 Comments | Article Rating

I have found a lot of new SQL blogs lately. Here are the top 5 top 10 in no particular order. I am going to try to make this a monthly post.

While they may be new to me, they may not be new. I am going to try to stick with ones that  A) have good content and B) may not be getting enough attention. It is hard for me to judge B. It mostly just based on my perception which could be wrong. :)

So if you are not on the list don’t take offense. Nothing personal but your blog sucks. Just kidding!

1.

SQL Fool (WWW, RSS)

Author: Michelle F. Ufford

Recent Highlight: Performance Comparison of Singleton, XML, and TVP Inserts

2.

Facility 9 (WWW, RSS)

Author: Jeremiah Peschka

Recent Highlight: Mirroring table changes through DDL triggers

3.

TJay Belt (WWW, RSS)

Author: TJ Belt

Recent Highlight: #PASS Board of directors candidates

4.

The Rambling DBA (WWW, RSS)

Author: JONATHAN KEHAYIAS

Recent Highlight: What am I reading? : SQL Server 2005 Practical Troubleshooting: The Database Engine (Ken Henderson)

5.

Home of the Scary DBA(WWW, RSS)

Author: Grant Fritchey

Recent Highlight: PASS Board Elections

6.

SQLBatman (WWW, RSS)

Author: Bruce Wayne aka Thomas LaRock

Recent Highlights: PASS Elections

7.

Kendal Van Dyke (WWW, RSS)

Author: Kendal Van Dyke

Recent Highlight: Delegation: What It Is And How To Set It Up

8.

SQLAGENTMAN (WWW,RSS)

Author: Tim Ford

Recent highlight: SQLSERVERPEDIA WIKI

9.

Arcane Code(WWW,RSS)

Author: Robert C. Cain

Recent Highlight: SQL Saturday Orlando Full Text Searching Session

10.

SQL Dumbass (WWW, RSS)

Author – ?

Recent Highlights: Backups and Boat Drinks

email it! |   |   | 

Why do I have to use a MERGE\HASH JOIN Hint?

Posted by Jason Massie Click to IM Jason Massie on Saturday, November 15, 2008 at 8:04 PM to SQL Server 2008, SQL Server 2005, query optimizer, SQL performance tuning
2437 Views | 4 Comments | Article Rating

Hash match operator iconI have run into this several times lately so I thought I would whip out a quick post.

The scenario

A query runs much faster with a hash join hint than a nested loop but that is what the optimizer is choosing.

High level background

Merge and hash are good when you are working with lots of rows because it can leverage sequential IO. If you do a nested loop join with lookups on 100-1000+ rows, the random IOs can be 10-1000% more expensive than a sequential scan.

Why?

So why does the optimizer choose a nested loop? I have seen it is because the optimizer had to make a best guess at how make rows were being returned. It most cases, the optimizer guesses 1 row will be returned so a nested loop is the best choice as far as the optimizer can tell.

Identifying the problem 

Identifying the problem is pretty easy. All you need to do is look at the query plan. It can be text, xml or graphical. Look actual and estimated rows returned. If the actual rows are 11teen,000,000 but the estimated rows is 1 then this may be the problem

Causes

I most often see this when large table variables, local variables or modified stored procedure parameters are involved. There can be other causes. See my favorite white paper.

Fix?

Easy. Don’t use table variables and local variables. If you have to modify sp parameters, pass them to a nested stored proc. Make sure stats are up to date. If the WHERE cause is complex, try putting the logic in a persisted computed column or indexed view. Another option is to use a covering index. Of course, the last resort is the JOIN hint.

Need more?

Want to get real deep on stuff like this? Check out Craig Freedman’s blog or his Inside SQL Server 2005 chapters.

email it! |   |   | 

5 Quick Tips for the Query using the “Wrong” Index

Posted by Jason Massie Click to IM Jason Massie on Thursday, October 30, 2008 at 10:59 PM to SQL Server 2008, SQL Server 2005, query optimizer, Indexes
1537 Views | 1 Comments | Article Rating

I quote “wrong” because with the info the optimizer has, it thinks it has the right index. :)

1. Look for cardinality problems. You can do this by looking at the actual rows versus estimated rows in the query plan. If they are off, chances are you are not following the best practices listed here.

2. Conversions in the WHERE clause can cause issues. Be sure to look at query plan for implicit conversions

3. Complicated logic in the WHERE clause can also cause problems. Consider indexed persisted computed columns or indexed views.

4. Constraints give the optimizer more info when choosing a plan with the “right” index. It can take a PK or unique constraint into consideration but it does not know about similar logic in a trigger.

5. Large datasets are being returned but the index is not covering. An index with just the columns in the WHERE clause is ok if just a few rows are returned but it does not take much for an index scan to be more efficient.

#1 is the most important one because the link gives 5 or 7 more reason why the “wrong” index is chosen.

P.S. If all else fails, update stats and if that does not work, make the index covering.

email it! |   |   | 

This Update Came from SQL Server

Posted by Jason Massie Click to IM Jason Massie on Wednesday, October 29, 2008 at 9:38 PM to SQL Server 2008, SQL Server 2005, tsql, social networking, security, Humor
1782 Views | 3 Comments | Article Rating

Disclaimer:

Just because you can does not mean you should and even if you should, use with care. For example, you will have no friends after a day or so of updating your facebook status every time a tlog backup runs on your farm. There are also many security concerns to consider. That said, I can think of a few uses for SQL Server Web 2.0 mashups and I am not all that creative.

How it works

Sign up at http://ping.fm and then sign up at whatever services you want to update from SQL. Here is a list of what they currently support. From SQL, we could send a message to twitter or even better, yammer via database mail. Here is the obligatory, “Don’t send anything confidential over email”

Ping.fm is a simple service that makes updating your social networks a snap!

Possible Uses

Augmenting your monitoring – The keyword is word is “augmenting” except for the smallest installations. For the crown jewel of the company, you might get a call from the 24/7 staff and an email. Why not a tweet too especially if it can add SMS functionality that you may not currently have?

Turn X into an RSS feed – Where X could be, all job executions, any SEV error messages, any trace event or DDL operations, or [your idea here]. You can funnel the RSS into the intranet, your reader or [insert creative idea here].

An insert trigger on your press release table – Blast it to the world. Some companies are already doing similar things http://dell.com/twitter.

Personal updates from the SQL Editor – I don’t know about you but I have spent weeks on end in tsql. Some deadlines don’t allow for time to come up for air. It would pretty cool in a geeky way to tell the world that I just replaced 500 lines of cursor code with a 10 liner or whatever without leaving SSMS.

 

Example Code:

sp_configure 'show advanced options', 1;

GO

RECONFIGURE;

GO

sp_configure 'Database Mail XPs', 1;

GO

RECONFIGURE

GO

EXECUTE msdb.dbo.sysmail_add_account_sp

@account_name = 'Ping.fm demo',

   
@description = 'Mail account',

   
@email_address = 'jason@statisticsio.com',

   
@replyto_address = 'jason@statisticsio.com',

   
@display_name = 'Jason Massie',

   
@mailserver_name = 'mail.statisticsio.com' ;

-- Create a Database Mail profile

EXECUTE msdb.dbo.sysmail_add_profile_sp

@profile_name = 'MailAccount',

   
@description = 'Profile used for administrative mail.' ;

-- Add the account to the profile

EXECUTE msdb.dbo.sysmail_add_profileaccount_sp

@profile_name = 'MailAccount',

   
@account_name = 'Ping.fm demo',

   
@sequence_number =1 ;

-- Grant access to the profile to all users in the msdb database

EXECUTE msdb.dbo.sysmail_add_principalprofile_sp

@profile_name = 'MailAccount',

   
@principal_name = 'public',

   
@is_default = 1 ;

-- here is the magic blasphemy.
EXEC sp_send_dbmail @profile_name ='MailAccount', @recipients = 'YourUniqueEmail@ping.fm, @subject = 'Blogged:', @body = 'This update came from SQL Server http://ping.fm/XiEkj'

I just updated twitter, linkedin, facebook, plurk, rejaw from SQL!

In closing

One more time, pay attention to security. There are a few commercial products on the horizon. http://ping.fm and most of these service also have API’s that may be a better alternative than database mail. Finally, database mail was meant for administrative alerts and I suggest you stick with that mindset..

email it! |   |   | 

This week

Posted by Jason Massie Click to IM Jason Massie on Tuesday, October 21, 2008 at 7:14 PM to SQL Server 2008, SQL Server 2005, SSD, tsql, Boohoo
1461 Views | 0 Comments | Article Rating

I am in a what feels like a whirl wind tour of the globe so content may be light this week. Jetlagged in Denmark right now and should seriously be asleep. I have some interesting topics in the works but until then I have "suggested reading" at several places.

FriendFeed:

http://friendfeed.com/statisticsio

Google Reader Shared Items:

http://www.google.com/reader/shared/09956560379006770135

Facebook:

http://www.facebook.com/profile.php?id=1013730310&ref=profile

 

Google reader is probably the most SQL focused link. The others have google reader shares + stuff. If you are reading this, chances are you will find what I find cool at least slightly interesting as well.

 

email it! |   |   | 

"Adhoc Triggers"

Posted by Jason Massie Click to IM Jason Massie on Sunday, October 19, 2008 at 9:35 PM to SQL Server 2008, SQL Server 2005, tsql
840 Views | 1 Comments | Article Rating

This is a feature that I didn't even know existed until the recent SQL Server 2008  beta tests even though it was introduced in SQL Server 2005. So.... I wanted to pass it on.

Rob Farley:

OUTPUT clause - knowing what goes in, and what you've accidentally taken out.

Scott on Writing

OUTPUTing Data from the Just-Inserted, Updated, or Deleted Row(s)

Check it out and I believe there is room for improvement if there is demand so make requests at connect.

email it! |   |   | 

A Nasty SQL Bug - USERSTORE_TOKENPERM

Posted by Jason Massie Click to IM Jason Massie on Wednesday, October 15, 2008 at 9:59 PM to bugfix, SQL Server 2005
807 Views | 3 Comments | Article Rating

Executive: Um, the Internet is slow.

DBA: You mean the website?

Executive: I think it is the dataplace.

DBA: Database?

Executive: Yah, I rebooted my modem but it is still slow.

So your manager catches wind and comes running over. You pull open perfmon and CPU, memory\IO and network are idle. Blocking? Nada. You tell your boss that he ought to check with the App and Network guys.

However, it is a database issue in this specific instance.

This is not new news. Why am I blogging about this?

  • It is hard to diagnose.
  • I have run into it several times including today.
  • The users say it is slow but SQL looks happy.
  • This is hard to google unless you already know the problem.

The bug and hotfix is at this KB: http://support.microsoft.com/kb/933564    

PSS expands on it here: http://blogs.msdn.com/psssql/archive/2008/06/16/query-performance-issues-associated-with-a-large-sized-security-cache.aspx

email it! |   |   | 

New MVP

Posted by Jason Massie Click to IM Jason Massie on Wednesday, October 01, 2008 at 11:04 AM to SQL Server 2008, SQL Server 2005
824 Views | 17 Comments | Article Rating

I got the MVP nod from Microsoft. I am really grateful. It actually easy. I was just doing what I love to do and wasn’t expecting anything in return. I am not sure how I got noticed or who nominated me but thank you.

email it! |   |   | 

SQL Screencasts Galore

Posted by Jason Massie Click to IM Jason Massie on Tuesday, September 30, 2008 at 11:10 PM to SQL Server 2008, SQL Server 2005
803 Views | 1 Comments | Article Rating

I have been meaning to blog about this one. Sean McCown has a blog called the Midnight DBA with a huge series of screencasts. I think like 12 hours total.

“When the kids go to sleep I stay up to make videos.”

All free and downloadable. Good topics. The site is here and you can subscribe to the RSS here.

Sean also blogs for InfoWorld at the Database Underground. Some nice editorials to be found. The RSS subscription can be found here.

More info on Sean:

Sean McCown has been managing high-end transactional databases since 1995, and with terabyte databases since before they were common. His expertise is tuning databases for sub-second query performance. He has worked with IBM DB2, Microsoft SQL Server, Oracle Database, Sybase ASE, and many others including TeraData, MySQL, Ingres, and PostgreSQL. Sean has been a contributing editor to the InfoWorld Test Center since 2003, and he's written for many other publications including SSWUG.org, SQLServerCentral.com, SQL Server Magazine, and SQL Server Standard Magazine.

email it! |   |   | 

Buffer Pool Usage by Database

Posted by Jason Massie Click to IM Jason Massie on Tuesday, September 09, 2008 at 4:39 PM to SQL Server 2008, SQL Server 2005, tsql, memory bottleneck, consolidation
1999 Views | 1 Comments | Article Rating

Here is a quick query I wrote today. It is the first time I had to go to this DMV so I thought I would share. It would be useful when planning for consolidation and troubleshooting a bunch of apps that have been consolidated or are hosted in a shared environment. Once you find the database, you can break it down by object and index with Tom Davidson's query.

select db_name(database_id) as dbName, count(*)*8/1024 as BufferPoolMB
from sys.dm_os_buffer_descriptors
group by db_name(database_id)
order by 2 desc

email it! |   |   | 

SQL Server Videos

Posted by Jason Massie Click to IM Jason Massie on Friday, August 29, 2008 at 10:42 AM to SQL Server 2008, SQL Server 2005, Professional Development
1219 Views | 0 Comments | Article Rating

I ran across SQL Server videos on .netkicks (RSS). I think this is a fairly new site and I must say it is pretty nice. Good clean layout with RSS feeds to let you know when new stuff arrives. You can stream with WMP or silverlight AND you can download in 3 different resolutions plus ipod format. On top of all of that, there is a transcript of the video.

I watched the 400 level video on extra wide covering indexes. It was well thought out and I learned something new. What more could you want? Oh yah, it is free!

Update: You can also follow Michael on twitter here.

email it! |   |   | 

Breaking: Quest-SolidQ Partnership

Posted by Jason Massie Click to IM Jason Massie on Friday, August 15, 2008 at 4:20 PM to SQL Server 2008, SQL Server 2005, SQL performance tuning, Rumor mill, Rumor mill
6633 Views | 88 Comments | Article Rating

The podcast from Brian Moran and Bill Bosworth provides good insight into the the deal. Click here.

Here is an excerpt for the forthcoming press release:

Quest Software is announcing its new partnership with Solid Quality Mentors, a global provider of education and solutions for Microsoft data and development platforms.

This is not a sales reseller relationship, but a true joining of forces to provide new real value to the SQL Server community. Specifically, our plans are to work together in three specific areas: community outreach, product development and professional services.

Community outreach: The companies will work together on joint programs including speaking at Quest and Solid Quality Mentors events, authoring technical briefs and white papers and providing joint webcasts and podcasts for the SQL Server community.

Product development: Quest will collaborate with Solid Quality Mentors on product road maps and feature sets, drawing on their combined experience of real-world SQL Server challenges to provide the best solutions possible for SQL Server DBAs and developers.

Professional services: Quest customers will benefit from consulting services offered by Solid Quality Mentors to help implement tools and manage complex environments.

Peep http://quest.com Monday for more details.

email it! |   |   | 

More SQL experts than you can shake a stick at

Posted by Jason Massie Click to IM Jason Massie on Tuesday, July 29, 2008 at 10:57 PM to SQL Server 2008, SQL Server 2005
1116 Views | 2 Comments | Article Rating

Wow, there is a great article over on http://odinjobs.com. I would call it a virtual round table. It is basically the same interview with a 8 different SQL Server experts so you get some different and interesting perspectives. It is refreshing format. Definitely read of the month for me. Thanks for the plug, Brent!

 

blog_roll_01 The Panel Blogroll

 

The Articles.

http://www.odinjobs.com/blogs/careers/entry/sql_server_experts_ms_sql1

http://www.odinjobs.com/blogs/careers/entry/sql_server_experts_part_ii

http://www.odinjobs.com/blogs/careers/entry/sql_server_experts_part_iii

email it! |   |   | 

You know you are a SQL Wonk when...

Posted by Jason Massie Click to IM Jason Massie on Tuesday, July 22, 2008 at 1:47 PM to SQL Server 2005
770 Views | 2 Comments | Article Rating

You have have a favorite whitepaper... Mine is "Statistics Used by the Query Optimizer in Microsoft SQL Server 2005". Especially the the best practices section. What is yours?

wonk (wongk) noun : An expert who studies a subject or issue thoroughly and excessively.

I qualify. At least for the excessive part.

email it! |   |   | 

Stupid XML SSMS Trick

Posted by Jason Massie Click to IM Jason Massie on Tuesday, July 15, 2008 at 5:40 PM to SQL Server 2008, SQL Server 2005, tsql, Indexes
1377 Views | 2 Comments | Article Rating

This might be HAWTALTA for some of you. I just thought of doing this today even though I have been using xml showplan since I was knee high to a junebug. You can make query results clickable just by casting them as XML. For example:

select cast('select 1' as xml)

By clicking the resulting "select 1", a new query editor window opens with "select 1" ready to execute. This would be useful for scripts that generate scripts. Here is a practical example. (Forgive the formatting. I cannot get too wide in the post.)

SELECT  sys.objects.name
, (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) as Impact
,  cast('CREATE NONCLUSTERED INDEX ~NewNameHere~ ON ' 
+ sys.objects.name + ' ( ' + mid.equality_columns + 
CASE WHEN mid.inequality_columns IS NULL THEN '' 
ELSE CASE WHEN mid.equality_columns IS NULL 
THEN '' ELSE ',' END + mid.inequality_columns END + ' ) ' 
+ CASE WHEN mid.included_columns IS NULL 
THEN '' ELSE 'INCLUDE (' + mid.included_columns + ')' 
END + ';' as xml) AS CreateIndexStatement
, mid.equality_columns
, mid.inequality_columns
, mid.included_columns
FROM sys.dm_db_missing_index_group_stats AS migs 
INNER JOIN sys.dm_db_missing_index_groups AS mig 
ON migs.group_handle = mig.index_group_handle 
INNER JOIN sys.dm_db_missing_index_details AS mid 
ON mig.index_handle = mid.index_handle 
INNER JOIN sys.objects WITH (nolock) 
ON mid.object_id = sys.objects.object_id
WHERE     (migs.group_handle IN
(SELECT TOP (500) group_handle
FROM  sys.dm_db_missing_index_group_stats WITH (nolock)
ORDER BY (avg_total_user_cost * avg_user_impact) * (user_seeks + user_scans) DESC))
ORDER BY 2 DESC 

 

Here are what some of the results look like.

results

 

Update : You also have to associate the XML file extension with the SQL editor to be executable.

 extension

email it! |   |   | 

The Perils of SQL Profiler

Posted by Jason Massie Click to IM Jason Massie on Monday, July 14, 2008 at 3:02 PM to SQL Server 2008, SQL Server 2005, Procedure Cache, DMVs, Captain Varchar(MAX)
2463 Views | 8 Comments | Article Rating

profiler I posted the first Captain VarChar(MAX) comic last Friday. It takes a swing at profiler. A lot of you are like “Duh!”. I have just done too many dba interviews where the candidate’s default answer is profiler. The interview usually gets tough or really short at that point. Just say no to SQL profiler.

I really have to stretch my imagination to come up with a situation where using SQL Profiler sounds like a good idea. For example, you quickly want to capture “ordered” events when repro’ing a problem in your *test* environment AND you filter it by your SPID. Any other time, you are wasting lots of time, cause performances overhead and probably missing what you are looking for while digging for the needle in the haystack. Also contrary to popular belief, running the GUI on another machine DOES NOT help much. For the rest of the post when I refer to a trace, I am referring to one captured with a server side trace unless I say “profiler” or “GUI”

I will admit that I have brought a production app to its knees with profiler. Picture this. You get a call while you are running profiler that the app is having issues. At first you think, “Hey, I have a trace running so at least I will be able to pinpoint the problem.” Then you see TRACE_WRITE wait types. Your stomach knots up because you realize that you just caused a production outage. Don’t be that guy(or gal).

SQL 2005+ just gives you too much info through the DMV’s. 90%+ of the time you can use the DMV’s instead of Profiler. The other 10% of the time, use a server side trace not the Profiler GUI. I have never seen a server side trace bring down an app. Even unfiltered traces on highly transactional systems where a gigabyte+ is collected every minute. I can see it causing an issue but the server would have to be pretty max’ed out to begin with.

Lastly, a trace only reports CPU, Reads, Duration etc when the query completes. Query completion for a misbehaving query could take 10x to 100x longer than normal. This makes traces unusable in a lot of cases when troubleshooting.

Let’s look at some scenario’s:

Troubleshooting a performance issue that is currently happening

A SQL trace in this situation is almost never needed on SQL 2005+. I troubleshoot like this:

1) See if\what hardware subsystem is pegged out with about 5 or 6 perfmon counters.

a) Verify with DMV data or wait stats if needed.

2) Identify the problematic queries with the sys.dm_exec_% DMV's

3) Fix.

Here is the query I use. In a nutshell, it grabs a snapshot, waits a second and does a diff so I can see what is currently slamming the server. Otherwise, the cumulative CPU and IO columns might throw me off. I also grab the query plan which is easy here but very expensive in a trace and hard to correlate with the SQL completed event.

select r.cpu_time 
, r.logical_reads
, r.session_id 
into #temp
from sys.dm_exec_sessions as s 
inner join sys.dm_exec_requests as r 
on s.session_id =r.session_id --and s.last_request_start_time=r.start_time
where is_user_process = 1 
 
waitfor delay '00:00:01'
 
select 

substring(h.text, (r.statement_start_offset/2)+1 ,

((case r.statement_end_offset when -1 then datalength(h.text)

else r.statement_end_offset end - r.statement_start_offset)/2) + 1) as text
, r.cpu_time-t.cpu_time as CPUDiff 
, r.logical_reads-t.logical_reads as ReadDiff
, p.query_plan
, r.wait_type
, r.wait_time
, r.last_wait_type
, r.wait_resource
, r.command
, r.database_id
, r.blocking_session_id
, r.granted_query_memory
, r.session_id
, r.reads
, r.writes
, r.row_count
, s.[host_name]
, s.program_name
, s.login_name
from sys.dm_exec_sessions as s 
inner join sys.dm_exec_requests as r 
on s.session_id =r.session_id and s.last_request_start_time=r.start_time
full outer join #temp as t on t.session_id=s.session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) h
cross apply sys.dm_exec_query_plan(r.plan_handle) p
order by 3 desc
 
drop table #temp

 

Proactive performance tuning

Now this starts to get in to fuzzy territory. Technically, a SQL trace is more thorough than doing your analysis off of the procedure cache. However, I would say benefits outweigh the losses in most but not all cases.

Procedure Cache Pro’s

· No need to capture a trace

· No need to load a trace

· Aggregation already exists so the data can be smaller assuming that the application has good plan reuse.

· Easy access to XML Showplan

Procedure Cache Con’s

· Queries can be flushed until next execution for many reasons

· Some queries are not cached. These are usually queries that you don’t care about.

To replace SQL trace analysis with a DMV query, use something like this:

select total_worker_time/execution_count as AvgCPU  
, total_elapsed_time/execution_count as AvgDuration  
, (total_logical_reads+total_physical_reads)/execution_count as AvgReads
, execution_count   
, substring(st.text, (qs.statement_start_offset/2)+1 , 
((case qs.statement_end_offset when -1 then datalength(st.text) 
else qs.statement_end_offset end - qs.statement_start_offset)/2) + 1) as txt  
, query_planfrom sys.dm_exec_query_stats as qscross apply sys.dm_exec_sql_text(qs.sql_handle) as stcross apply sys.dm_exec_query_plan (qs.plan_handle) as qp
--where – filter as needed.
--group by – Consider striping literals and grouping by the SQL text. 
--See Inside SQL Server 2005 for more info.
--Order by – Sort as needed.

Uncommon cases

There are some less common uses of SQL traces like the blocked process report, deadlock report, recompile tracing and many others. Make sure you review all of your options and don’t forget about the WMI Provider for Server Events. Use your best judgment and avoid the GUI like the plague.

Conclusion

To summarize very briefly: Never use the SQL Profiler GUI, know your tools, and pick the best one for the job.

email it! |   |   | 

MS SQL Grows Faster Than Rivals in a Tight Race

Posted by Jason Massie Click to IM Jason Massie on Friday, July 11, 2008 at 4:53 PM to SQL Server 2005
544 Views | 0 Comments | Article Rating

Here is a quicky I just ran across.

Revenues for Microsoft (NSDQ: MSFT)'s SQL Server in 2007 grew at a rate of 14% over the previous year and at a rate that exceeded that of its principle relational database rivals, IBM (NYSE: IBM) and Oracle (NSDQ: ORCL), each with 13.3% growth.

Full article from InformationWeek.

 

The numbers look good when the following is considered:

  • Economic downturn
  • Most customers are already on SQL Server 2005 before 2007
  • Customers waiting on a battle tested Windows Server 2008 for tech refresh
  • Customers waiting on SQL Server 2008

I think the ones to watch out are are MySQL and Ingres. Come on with the PHP driver for SQL Server RTM and let it be good!

The article reports the following for the open source vendors:

Popular open source databases, such as MySQL, barely show up in market analysis based on revenues. MySQL charges a subscription for updates and technical support. Its revenues have grown from $16 million in 2005 to $38 million in 2007, giving it a 0.2% share of the relational database market last year. Those revenues were growing at 10.9%, IDC estimates, even though usage figures based on thousands of daily downloads would be much higher.

Ingres, an open source system after being spun out of CA (NSDQ: CA), accounted for 0.1% of the market's revenue, a growth rate nevertheless of 207% in 2007 compared to the previous year.

The problem is that most of the people using the software are not paying the vendor for support. They are being supported by 3rd parties like their hosting provider or other partner. Those beans are not being counted.

email it! |   |   | 

More on the SQL Security Issue

Posted by Jason Massie Click to IM Jason Massie on Tuesday, July 08, 2008 at 11:51 PM to bugfix, SQL Server 2005, security
833 Views | 3 Comments | Article Rating

One of the security vulnerabilities was discovered by iDefense. They released their public advisory today with more details here. Here is an excerpt:

Remote exploitation of an integer underflow vulnerability within Microsoft Corp.'s SQL Server could allow a remote attacker to execute arbitrary code with the privileges of the SQL Server.

The vulnerability exists within the code responsible for parsing a stored backup file. A 32-bit integer value, representing the size of a record, is taken from the file and used to calculate the number of bytes to read into a heap buffer. This calculation can underflow, which leads to insufficient memory being allocated. The buffer is subsequently overfilled leading to an exploitable condition.

The Microsoft Security Vulnerability Research & Defense blog provided even more info later today. The full post is here. Lets look at 3 sentences from this post that tells us this is really only dangerous if you are not following best practices to begin with.

  1. The vulnerability requires an attacker to be able to force the SQL Server to load a malicious MTF file from the local drive or from the network.
  2. In order to remotely exploit this vulnerability, the attacker could leverage a separate SQL injection vulnerability and then trigger the SQL Server to load a malicious MTF file from the Internet.
  3. Therefore, if you see SQL Server loading MTF files from the Internet, it is probably bad news.

Your app has to be injectable and it has to be open to port 80. If that is true, you are probably already running SQL as a domain admin or SA has a blank password. ;)

You should still test and deploy the hotfix ASAP. Do you trust all of the variables? Your code, MS's code, the disclosure.... Even if you do, there are still 3 other undisclosed vulnerabilities so get to patching. 

email it! |   |   | 

New SQL Server Security Hot Fix

Posted by Jason Massie Click to IM Jason Massie on Tuesday, July 08, 2008 at 12:11 PM to bugfix, SQL Server 2005, Windows Server 2008, security
1323 Views | 0 Comments | Article Rating

Well, it was a great run. SQL Server 2005's pristine security record is now tarnished. In fact, there has not been a new SQL Server security vulnerability since 2003. It looks like they took the SQL slammer lesson to heart.

"

Executive Summary

This security update resolves four privately disclosed vulnerabilities. The more serious of the vulnerabilities could allow an attacker to run code and to take complete control of an affected system. An authenticated attacker could then install programs; view, change, or delete data; or create new accounts with full administrative rights.

"

1. Memory Page Reuse Vulnerability - CVE-2008-0085

An information disclosure vulnerability exists in the way that SQL Server manages memory page reuse. An attacker with database operator access who successfully exploited this vulnerability could access customer data.

2. Convert Buffer Overrun - CVE-2008-0086

A vulnerability exists in the convert function in SQL Server that could allow an authenticated attacker to gain elevation of privilege. An attacker who successfully exploited this vulnerability could run code and take complete control of the system.

3. SQL Server Memory Corruption Vulnerability - CVE-2008-0107

A vulnerability exists in SQL Server that could allow an authenticated attacker to gain elevation of privilege. An attacker who successfully exploited this vulnerability could run code and take complete control of the system.

4. SQL Server Buffer Overrun Vulnerability - CVE-2008-0106

A vulnerability exists in SQL Server that could allow an authenticated attacker to gain elevation of privilege. An attacker who successfully exploited this vulnerability could run code and take complete control of the system.

The full article can be found here.

 

Don't know what "Windows Internal Database" is? I didn't either. Here is the wikipedia entry. I wonder if Windows 2008 will get an upgrade when Katmai RTM's.

 

Update: The binaries have been released. SQL 2005 gets bumped to version 9.00.3233.00. The direct x86 and x64 SQL 2005 download is here. Refer to the full article for 7.0, 2000, and express editions.

email it! |   |   | 

xSQL Software 4th of July Giveaway

Posted by Jason Massie Click to IM Jason Massie on Friday, July 04, 2008 at 11:19 AM to SQL Server 2008, SQL Server 2005
515 Views | 2 Comments | Article Rating

I ran across this on Digg. I have not had a chance to mess with the product yet but I have heard good things about their xProfiler tool. I just thought I would pass this on:

 

To celebrate the 4th of July instead of fireworks we have decided to give away 1000 RSS Reporter licenses worth $99 each. Hurry, only the first 1000 will benefit from this.

Important notes:

  • One license per person / organization only.
  • Any license you obtain from xSQL Software can not be resold

FREE RSS Reporter 5 SQL Server Instances License - a $99 value, no strings attached
To receive your free licenses:

  • Go to the RSS Reporter order page here
  • Select the "5 SQL Server Instances" license
  • When you reach the shopping cart page plug in the special discount code: JULY4GIVEAWAY on the "Discount" text box and click the "Update Cart" button to apply the 100% discount.
  • Enjoy the product and send us your comments and suggestions!

Expiration: this offer expires at the end of the day on July 4, 2008.

 

Here is the scoop on RSS report from their site:

RSS Reporter

Generate standard RSS feeds for SQL Server job status, ad-hoc queries, database size and space usage.

  • Jobs from multiple SQL Servers into one RSS feed

  • Drill down on a job RSS feed to see the details

  • Filter and sort job feeds by status, execution time, etc.

  • Graphical database size/space RSS feed

  • Turn any T-SQL query into a standard RSS feed

  • Access feeds anytime from any connected device

  • Supports SQL Server 2005 and SQL Server 2000.

 

While you are at it, check out the rest of their products.

email it! |   |   | 

CXPACKET, MAXDOP and your OLTP system

Posted by Jason Massie Click to IM Jason Massie on Thursday, June 26, 2008 at 5:15 PM to SQL Server 2005, query optimizer, SQL performance tuning, tsql, DMVs
7044 Views | 6 Comments | Article Rating

So you are experiencing CXPACKET wait types? If you run a google search, you will quickly find out you are experiencing the dreaded SQL Server parallelism problem and you must reduce MAXDOP to 1. While that is possible, I say most likely not. I say that, most of the time, SQL is doing the best it can with what it has to work with. That is the query, the data and the schema.

Microsoft has come a long way since version <= 7.0 when it comes to parallelism. If your OLTP queries follow best practices and are well indexed, they probably will never generate a parallel plan. This is because they are fast and access a small amount of rows. If they are missing indexes or SQL overestimates cardinality, SQL might decide to do scans, sorts, hashes, spools etc. These iterators, among others, can go parallel to reduce execution time at the cost of system resources. These iterators are not bad and they do have their place. It just isn’t on OLTP type of queries most of the time.

So dropping the MAXDOP on an OLTP system to 1 probably won’t hurt much because most of the time there is an IO bottleneck. If the CXPACKET wait types are a symptoms of poor indexing and row count estimation, it won’t help either. Whole books have been written on indexing, query tuning and there is a nice whitepaper on stats best practices to avoid estimation problems so I am not going to go into that. I will give you some pointers on quickly identifying whether the CXPACKET is a symptom or the cause.

So your boss and boss's boss run over to your desk yelling about the customer complaints of slowness with SQL. You run this query or something similar:

select r.cpu_time 
, r.logical_reads
, r.session_id 
into #temp
from sys.dm_exec_sessions as s 
inner join sys.dm_exec_requests as r 
on s.session_id =r.session_id --and s.last_request_start_time=r.start_time
where is_user_process = 1 
 
waitfor delay '00:00:01'
 
select substring(h.text, (r.statement_start_offset/2)+1 , ((case r.statement_end_offset when -1 
then datalength(h.text)  else r.statement_end_offset end - r.statement_start_offset)/2) + 1) as text
, r.cpu_time-t.cpu_time as CPUDiff 
, r.logical_reads-t.logical_reads as ReadDiff
, p.query_plan
, r.wait_type
, r.wait_time
, r.last_wait_type
, r.wait_resource
, r.command
, r.database_id
, r.blocking_session_id
, r.granted_query_memory
, r.session_id
, r.reads
, r.writes
, r.row_count
, s.[host_name]
, s.program_name
, s.login_name
from sys.dm_exec_sessions as s 
inner join sys.dm_exec_requests as r 
on s.session_id =r.session_id and s.last_request_start_time=r.start_time
full outer join #temp as t on t.session_id=s.session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) h
cross apply sys.dm_exec_query_plan(r.plan_handle) p
order by 3 desc
 
drop table #temp
 

You notice that you have several rows with CXPACKET wait types. With this query, you click the xml show plan link and:
1.    search the xml for missing indexes.
2.    Save as a .sqlplan and reopen in SSMS
3.    Compare estimated and actual rows in the iterators on the right side of the plan. Poor estimates may bubble to the left as well.
4.    If there are no missing indexes, estimates and actual are fairly close, reducing MAXDOP may help if it is not a huge report or query.

5. If there are missing index or bad estimations, fix it! :)


Of course, these are not rules set in stone. Just a style in the art of database administration. Just don't blame it on a "parallelism bug" because it is a poor musician that blames his instrument.

One thing to note, if you do turn down MAXDOP server-wide, turn in on at the query level(enterprise edition) on your index operation because they are optimized for it.
Alter index all on tblBlah rebuild with (maxdop=32);

email it! |   |   | 

Open Source SQL Server projects on CodePlex

Posted by Jason Massie Click to IM Jason Massie on Sunday, June 22, 2008 at 7:13 PM to SQL Server 2005
2715 Views | 3 Comments | Article Rating

I was perusing CodePlex and I noticed some new and interesting projects. This is the search that I used. Just sort by release date. There are a ton of projects but these are the ones that I found interesting.

SQL Server Cache Manager

"SQL Server Cache Manager will allow you to return information about what is stored is the SQL Server cache and how efficiently it is being used."

sqlServerCacheManager

This is ubercool especially if you are not intimate with sys.dm_exec_query_stats. I admit that I probably will not use this much though. I already have my analysis queries written. I am used to them plus I can CROSS APPLY sys.dm_exec_query_plan to get the xml show plan.

 

Open DBDiff

"Open DBDiff is a open source database schema comparison tool for SQL Server 2005."

Open

Nice looking tool if you don't use Data Dude. They also mention that support for MySQL and SQL2000 is coming.

 

SQLServerFineBuild

"SQLServerFineBuild provides 1-click install and best-practice configuration of SQL Server 2005."

One-click Install of SQL Server 2005
  • The standard build includes Service Pack, Cumulative Update hotfix, community tools, and best-practice configuration.
  • The builds can be deployed manually or by a distribution tool such as Altiris.
Highly Customizable
  • Each site can edit the Configuration File to include site standards.
  • Site-specific components can be included in the FineBuild process
Pre-Configured Standard Builds
FineBuild delivers 4 standards builds:
  • Default Server build - for multi-drive servers
  • Named Instance build - adds another SQL Server instance to a server
  • Workstation build - for single-drive desktop machines
  • Client Tools build - just the tools, to allow remote administration of SQL Server

I am definitely going to give this one a try next time I have to do a 2005 install.

 

This are just the 3 that I thought were new and notable. Check out the full list.

email it! |   |   | 

Friendfeed SQL Server Room

Posted by Jason Massie Click to IM Jason Massie on Thursday, May 22, 2008 at 6:58 PM to SQL Server 2008, SQL Server 2005, Offtopic
655 Views | 2 Comments | Article Rating

I am sitting in the Tucson Airport. My flight is running late :( I just got done shooting 3 sessions for SSWUG's virtual conference. I think it went well but it is odd being in front of a camera instead of an audience. Anywhoo...

Friendfeed is a life streaming app that is an RSS aggregator with nice social interaction. It is a startup from ex-google employees and it is growing very fast. With a little bit more functionality, they are going to blow away facebook and twitter before too long.  Friendfeed and google reader is where I spend the majority of my time on the innardwebs these days.

They launched "rooms" today. I created a SQL Server room. Right now, you cannot add RSS feeds but you can post comments, links and other stuffs.

http://friendfeed.com/rooms/sqlserver

So sign up, join up and participate.

email it! |   |   | 

Page 1 of 2First   Previous   [1]  2  Next   Last   


Copyright 2006 by Statistics IO, My SQL Server Blog