What is Page Life Expectancy (PLE) in SQL Server

Being a production DBA means having to quickly look at a SQL Server and diagnose issue with it. We know that a quick look at perfmon or task manager can tell us of high CPU usage, but what is a good way to quickly look at proper memory usage.

Checking out the Page Life Expectancy (PLE) counter is a great way to check for memory pressure. A value too low for your system indicates that pages are being flushed from the buffer pool too quickly. The longer a page can stay in the buffer pool and be read from memory the better. We all know that having to constantly go back to disk to fetch data is costly.

I won’t get into the specifics of which number is too high or too low for a PLE counter, but I will say that any system in the double digit seconds is bad.  I have seen systems in single digits and some systems that I measure PLE in days.  I have updated my query to reflect those situations. I also like to include the uptime counter just in case I get on a system that SQL was recently restarted, if the server has only been up for 10 minutes, I cannot expect the PLE counter to be more than 10 minutes.

I highly recommending trending this value during the day to monitor usage on your servers. If you find this value consistently low it does not mean you need to rush and add more memory, you should first look at your queries and indexes to make sure you are not reading unnecessary data.  One bad query “select * from bigtable” can crush your PLE counter.

I have included two screen shots showing the results from two servers, one showing in days and one in hours.

PLE_Screenshot

 

Notice on the image above that the PLE is the uptime of the server.

PLE2

In the image above the server has been up for almost two weeks and has a PLE of 235 minutes.

SELECT  @@servername AS INSTANCE
,[object_name]
,[counter_name]
UPTIME_MIN = CASE WHEN[counter_name]= ‘Page life expectancy’
          THEN (SELECT DATEDIFF(MI, MAX(login_time),GETDATE())
          FROM   master.sys.sysprocesses
          WHERE  cmd=‘LAZY WRITER’)
      ELSE ”
END
, [cntr_value] AS PLE_SECS
,[cntr_value]/ 60 AS PLE_MINS
,[cntr_value]/ 3600 AS PLE_HOURS
,[cntr_value]/ 86400 AS PLE_DAYS
FROM  sys.dm_os_performance_counters
WHERE   [object_name] LIKE ‘%Manager%’
          AND[counter_name] = ‘Page life expectancy’

 

Share
Posted in Query Tidbits, SQL Tuning, SQLServerPedia Syndication | Tagged , | Leave a comment

SSIS training for a cause

logoOn Thursday March 14th (PI Day) in Duluth GA, Audrey Hammonds and Julie Smith will put on a spectacular SSIS training event to benefit the Cloverleaf School of Atlanta.

Both Audrey and Julie are SQL Server MVP’s and have given a countless amount of their time to the SQL Server Community over the years. Visit their blog at http://datachix.com/ They have spoken at events all over the country and always draw a crowd. I have had the privelage of working with them to plan SQL Saturday 89 and SQL Saturday 111 in Atlanta.

The day of training will be split into two parts.

Part I Dimensional Modeling with Audrey

  • Why Transactional databases are the way they are—Codd’s rules to live by
  • Why Codd’s rules don’t work for Reporting– Kimball’s rules to live by
  • Fun at the whiteboard converting a transactional model to a dimensional model.

Part II Extract Transform and Load using SSIS with Julie

  • A tour of SSIS
    Control Flow Basics
    Data Flow Basics
  • How to load Dimensions with SSIS
  • How to load Facts with SSIS
  • Why SSIS has got such a bad rap sometimes.
  • Frameworks
  • What happened and when
  • When things go wrong, how to know the details
  • Top quirks of SSIS—what, why, and how to get around them.

You don’t want to miss out on this training. Check out the event on Eventbrite. There is an earlybird rate so you don’t want to miss out. Don’t forget, the proceeds for this training go to a great cause.

Share
Posted in SQLServerPedia Syndication, Training/Events | 1 Comment

How to break a high end de-duplication backup device

I have been working with a client recently who purchased a nice top of the line de-duplication backup device in order to synchronize backups between two data centers. This device is very nice in how it will de-duplicate data to reduce storage needs and also compress the data. It will then synchronize the data to a secondary device hundreds of miles away.

These types of devices are not cheap and work very efficiently. My client got their SQL Server environment migrated to the new backup appliance and found a nice vulnerability within the device. Their previous backup solution maintained the retention policies whereas this new device did not. After using the new solution for a few months they notice performance decreasing almost to the point of moving back to their old solution.

After a couple of days of research into the issue it was ruled that the root cause was having too many files in the backup directory. Since several of the servers contained databases with low RPO’s, they were making lots of transaction log backups. Several of the tlog backup folders contained 10′s of thousands of backup files all with similar names.

Once the tlog folders were purged the system returned to a normal operational level. It was explained to the client by the vendor that they shouldn’t have more than 1000 files per folder and no more than 1000 subfolders.

The first lesson is that anytime you fundamentally change a solution of a critical process, you need to have a process in place to account for every aspect of the previous solution. Had this client built a proper purge process, they would not have brought a top of the line backup device to its knees.

The second lesson is that if you are making frequent transaction log backups for a system with multiple databases on it, you should consider writing the transaction logs to individual sub folders. The best practice would be to have a tlog folder with a sub folder for each database.  Having this in place will limit the number of files per directory.

Share
Posted in Backups/Recovery, SQLServerPedia Syndication | 1 Comment

SQL Backup and Recovery – new distribution

sqlbackupandrecoveryI recieved an email today from my publisher Joes 2 Pros that my book was now available on Barnes and Noble’s website in addition to Amazon in print and Kindle. This is very exciting.

In just three months SQL Backup and Recovery has sold nearly 500 copies. I am still in awe that my name is on the cover of a book and I really hope this is the beginning of many more to come.

It is such an educational process to write a book.

 

Share
Posted in Backups/Recovery, SQLServerPedia Syndication | Leave a comment

SQL Saturday 220 Atlanta GA

sqlsat220_webThat latest installment of SQL Saturday Atlanta was just announced. On May 18th 2013 SQL Server experts from all over will come together in Atlanta GA for a full day of free training.  I have been part of the previous two years SQL Saturday events in Atlanta and have had a blast volunteering and helping to put on such an incredible event that changes peoples careers and lives.

This past year for SQL Saturday 111, I recall various attendees and speakers referencing our event as the “SQL Family Reunion”. I must say that for SQL Saturday #220 we are aiming for the same feeling. We anticipate over 900 registrations. Last year we had over 170 sessions submitted for speakers. Over the past 1 hour that our event has been live to register and submit sessions we have had 5 speakers sumbit sessions.

If you would like to attend or submit sessions, makes sure to do so quickly.

Last year we hosted three pre-cons. We will have pre-cons again this year and those events should be live soon.

Visit our link and register today!!!

Share
Posted in SQLServerPedia Syndication, Training/Events | Leave a comment

Performance Impact from Page Splits

Recently I was brought in to help troubleshoot performance issues on a database server.  Going through my typical check list I noticed memory pressure on the box and made the recommendationof more memory which was simple to fix. What caught my attention though was that blocking was occurring on a transaction that was trying to do a simple delete of a few records.

In a discussion with the vendor I learned that this system does massive inserts and deletes all day long. This system had only been in place for a few months and one table was nearly 30 GB in size. This was the particular table that was being blocked with a delete of a few records. We use a standard index maintenance script that reorg’s or rebuilds based on fragmentation so I was able to quickly rule out fragmentation as the issue however I still felt like I should dig into the indexes to see what was happening.

In looking at the indexes I found a clustered index that was the primary key nvarchar(255) and 13 non clustered indexes all with the default fill factor of 100%. In digging into looking at the number of page splits per second on this instance they were in the several hundred. Taking a look at the top 10 indexes with page splits, this particular table was 8 of the 10. With this information in hand I went back to the vendor. They basically told me that this level of trouble shooting and tuning was beyond their knowledge but that what I stated sounds good and to implement the changes. All I asked them was if they had an issue with me rebuilding the index and dropping the fill factor rate. :)

In dropping the fill factor from 100% to 80%, I decreased the page splits drastically. For the overall instance I am no longer in the 100′s per second, they are still active in the 20+ range and for my top 10 indexes this particular table only has one entry. With that being said, I still have more work to do, however this system is in much better shape. The table grew quite a bit but the tradeoff is well worth it.

Share
Posted in SQL Tuning, SQLServerPedia Syndication | 8 Comments

PASS Summit 2012 – Networking

I was fortunate to attend my 4th PASS Summit. For the past 4 years I have flown out to Seattle Washington and attended the largest Microsoft SQL Server convention in the world. My first year was all about attending sessions and learning new things. Year two was about attending technical sessions and hanging out with a few friends I had made on twitter the year before. Year three was as much about hanging out with friends as it was attending technical sessions. This year I only attended two sessions and all day Tuesday meetings regarding volunteer work. Since this year my official company training event was a SQL Skills Immersion event, my trip to Seattle was technically vacation time for me. I spent my days hanging out with friends and making new ones.

I was very fortunate to be able to publish a book “SQL Backup and Recovery” with Joes2Pros. We made it to print just in time for the PASS Summit. I spent some time at the Joes2Pros booth hanging out with Rick Morelan, Tony, Greg and Pinal Dave as well as the Idera booth where I was a featured guest for a question and answer session on Wednesday and Thursday. I was very lucky that the Joes2Pros booth and Idera faced each other.

It was great getting to see the Joes2Pros team in person. Pinal Dave and I were able to spend a good bit of time together in the expo hall meeting people from all over the world, talking about our experiences with SQL server, book ideas, and getting to know one another better. It was a lot of fun having Pinal Dave and Rick attend my book signing Wednesday night at the Idera Happy Hour. Thursday night Pinal and I joined Brian Moran and Joey D’Antoni for some appetizers before Pinal and I walked to the friends of RedGate dinner. From the RedGate dinner we took a cab to the Microsoft appreciation party and ended the night meeting up with Rick, Tony and Greg for drinks. We had a blast. Friday was more meet and greet with people at the expo hall although I did take in a session that morning. I had a book signing at the Joes2Pros booth during lunch and gave out over 100 books. Pinal and I were joined by Rick at Subway for a late lunch and then we helped break down the Joes2Pros booth.

As the Summit was wrapping up Rick, Pinal and I camped out in the Community Zone and discussed upcoming projects. I must say that I am really excited to be working with Pinal and Rick. If things go as planned, there should be several new books in 2013 that I am involved with. Getting to know Pinal as more than a blogger has been a real treat. As most of you know, Pinal runs SQLAuthority.com, but he is also a husband, father, author and all around great guy. He is also someone I can now call a good friend. To the left is a picture from my first book signing in which Pinal was first in line to show support.

Back in August at a SQL Skills Immersion event, I met for the second time another great guy who goes by the name David Klee (blog). I first met David in Chicago after being introduced by Andy Galbraith. During the Immersion event I had asked a couple of questions about SQL on VMWare and boy did I hit the jackpot having David in the room. David and I have kept in touch and was able to spend some time catching up in Seattle. I have been very impressed with how much David has gotten involved in the SQL Community and sharing his deep depth of knowledge about VMWare with the community.

There are countless others that I connected with in Seattle and I am very much looking forward to reconnecting again at the various SQL Saturday’s in 2013 and the SQL PASS 2013 conference! October 15-18 in Charlotte, NC! Use the alumni code ALUMNI3D to get $100 off your early-bird registration!

Share
Posted in Backups/Recovery, Presentations, SQLServerPedia Syndication, Training/Events | Tagged , , | 1 Comment

Instant File Initialization with TDE

If you are using Transparent Data Encryption TDE and have Instant File Initialization turned on, you are not getting the benefits of Instant File Initialization.

Microsoft does not provide many details around the reasoning why but I would have to assume that since data is encrypted at the page level, that TDE has to still zero out the file. You can read what Microsoft has to say on TDE here

Share
Posted in SQLServerPedia Syndication | Leave a comment

Scripting out users

Many of us know the importance of scripting out our users on a regular bases in order to be able to before DR restores more efficiently.  If you are responsible for performing backup and restores or disaster recovery solutions and you do not have a routine to regularly script out your users and permissions, then you should implement one soon.

A common problem when DBA’s have to restore production user databases to another server is that none of their users exist on the new server. Depending on the level of disaster, you may not have access to a working master database on the primary server. You would then find yourself having to manually create the users or add AD users to the new server, or have to restore the master database from the old server and script the users out.

You don’t want to be in that type of situation. Microsoft provides us a nice sp_help_revlogin script that will easily script out your users. The issue with this script is that it does not include the users permissions. Luckily this is not a brand new issue and my friend Kendal Van Dyke (blog)has published a great article with the scripts on how to get your users permissions and roles. Check that out here.

A common problem that you may face if you are testing out the user create scripts is that if you try to run the script to create users on a server that does not support the complexity requirements or has a more strict password requirement, the script may fail.  You may get an error message similar to “Invalid value given for parameter PASSWORD”.

A good practice would be to implement a process to run both of the scripts above to output the values to a file that you backup each night with your databases. There are plenty of documentation available on the web to help you get the output into text files. I use sqlcmd and bcp to get the output into the format that I need. I have seen others that just create a two step job and use the “Output file:” option to save the results to a file. I got more complex so that the files I create are ready to execute as part of my DR policy without requiring any modification to the results.

I hope you found this helpful and that you have a solid recovery plan that you rehearse on a regular basis. Something you should try is to get someone completely unfamiliar with SQL Server and have them execute your recovery plan. If they can not follow it completely and recover your system, update your recovery plan. Who is to say that when disaster strikes, that you are available with your institutional knowledge to bring the system up. Who is to say that your priority will be your company if disaster strikes. With the recent events in New York and New Jersey with hurricane Sandy, where would your priority reside? Trying to fail over your company to another datacenter or finding food and shelter for your wife/husband and kids? If you spent the time and have a fool proof recovery plan that has been executed and tested multiple times, you could be rest assured that the support staff in that remote datacenter could execute your recovery plan to bring your company back online. Do yourself the favor, plan for the failure and test the plan.

Share
Posted in Backups/Recovery, SQLServerPedia Syndication | 1 Comment

SQL Backup and Recovery

I was very fortunate to have the opportunity to write a book for Joes2Pros on a topic that is very important to me. As database professionals, few things are more important than being able to properly backup and recover our data.

I had put together a presentation for user groups and SQL Saturday’s titled “Know Backups, Know Recovery”. It was during my presentation in New York City at SQL Saturday 158 that Rick Morelan heard me speak and told me he thought my session would make a great book. Over the next few weeks we shared a few emails and on September 14th we officially began the work. Several weeks later on October 31st, my book “SQL Backup and Recovery” went live on Amazon for the low price of $9.99.

I am very excited to have finally written a book, but more importantly to be able to share my experiences and help others through their journey to becoming a database professional. I wouldn’t be where I am today without the support of my family, that includes my SQL family as well. You all have been amazing to me and I love being able to pay it forward. So continue your support and go out and buy my book. :)

I will be having a book signing Wednesday night at the Idera Happy Hour at Fox Sports Grill and another book signing on Friday at the Joes2Pros booth during the second hour of lunch. If you are going to be at the PASS Summit, come see me.

Share
Posted in Backups/Recovery, SQLServerPedia Syndication | 4 Comments