Friday, September 5, 2014

High PLE high Performance.

Page Life Expectancy commonly called as PLE,  is number of seconds a page will stay in the buffer pool. 
The longer the pages stays in memory cache, the higher the PLE is, the high PLE gives high performance. Each time request comes, first SQL Server will check in the memory cache if it exists or not. If the results or data is found in memory cache (which is also called as buffer pool) decreasing the search time, then it will display the results that is read from cache. If sql server could not find the information in cache then it will look for the data in pages (that is stored in hard disk) now we are increasing the search time. So the high PLE leads to high performance. Below is the query to check the PLE value. 

select 
[object_name],
[counter_name],
[cntr_value] as Current_value
from
sys.dm_os_performance_counters
where
[object_name] LIKE '%Manager%'
and
[counter_name] = 'Page life expectancy'

Also always Buffer cache hit Ratio should be 100 or close to 100.
Below is the query to check the Buffer cache hit Ratio.

Both values can be obtained from Perfmon tool by adding respective counters.

select 
[object_name], 
counter_name, 
cntr_value as current_Value
from 
sys.dm_os_performance_counters
where 
[object_name] LIKE '%Buffer Manager%'
and
[counter_name] = 'Buffer cache hit ratio'

Thursday, September 4, 2014

SQL Server Error Log Recycle (ERRORLOG file growing large)


SQL Server Error log is too large and has grown upto 24GB, it takes a lot of time to open and sometimes hangs and SSMS gets into not-responding state.

Go to the location of the error log and see what's the size as shown in the pics below.
If you don't know the location of file, open management studio new query and execute the below query

use master
go
xp_readerrorlog 0, 1, N'Logging SQL Server messages in file', null, null, N'asc' 
go

From the results set in the text column you can find the location of your error log file.

Recycle log means creating the new error log file to start recording events in the new file so that its easy to search something in a new file rather that has fewer events rather than searching large file takes time.

Open management studio connect to the Instance, open new query.
and run the following statement.

use master
go
exec sp_cycle_errorlog
go


New ERROLOG file will be created by renaming the older file (24Gb) to ERRORLOG.1. You can comfortably delete the file to save space if you don't need it.
and expand the management studio you will see two files.

1) Current being the new file and starts to record new events.

2 Archive being the old recorded events, if you don't need it you can delete the physical file from the location.