Friday, December 27, 2013

Shrinking of transaction log file and other maintenance DB best pratices

Shrinking of transaction log file
SQL Server cannot move log records from the end of the log file toward the beginning of the log file. This means that SQL Server can only cut down the file size if the file is empty at the end of the file. The end-most log record sets the limit of how much the transaction log can be shrunk. A transaction log file is shrunk in units of Virtual Log Files (VLF). You can see the VLF layout using the undocumented DBCC LOGINFO command, which returns one row per virtual log file for the database: 

DBCC LOGINFO('myDatabase') 
FileId
FileSize
StartOffset
FSeqNo
Status
Parity
CreateLSN
2
253952
8192
11
0
128
0
2
253952
262144
13
0
128
0
2
270336
516096
12
0
128
7000000025000288
2
262144
786432
14
2
128
9000000008400246

The interesting column is "Status". 0 means that the VLF is not in use and 2 means that it is in use. In my example, I have 2 at the end of the file (read result from top to bottom) and this means that the file cannot currently be shrunk. How to handle this depends on your recovery model. You should adjust and replace options and database appropriately for below code. If you are uncertain, then check the command in the product documentation:
  • Simple recovery model
    USE dbname
    CHECKPOINT--First param below is fileno for log file, often 2. Check with sys.database_files
    --Second is desired size, in MB.
    DBCC SHRINKFILE(2500)DBCC SQLPERF(LOGSPACE--OptionalDBCC LOGINFO --Optional
    Now repeate above commands as many times as needed!

  • Full or bulk_logged recovery model
    USE dbname
    BACKUP LOG dbname TO DISK = 'C:\x\dbname.trn'--First param below is fileno for log file, often 2. Check with sys.database_files
    --Second is desired size, in MB.
    DBCC SHRINKFILE(2500)DBCC SQLPERF(LOGSPACE--OptionalDBCC LOGINFO --Optional
    Now repeate above commands as many times as needed!
What you end up doing is empty the log (CHECKPOINT or BACKUP LOG) and DBCC SHRINKFILE several times, so that SQL Server can move the head of the log to beginning of the file and also so the end of the file becomes unused. Investigate the layout of the log file using DBCC LOGINFO in between.

In:


Other references:


Friday, April 5, 2013

System timer interval 15ms

Windows default system timer interval is 15,6ms


This setting is only possible to change over development.

You can check the current offset using the following commnad:

powercfg /energy


it will create a xml file where you can find:



Platform Timer Resolution:Platform Timer Resolution
The default platform timer resolution is 15.6ms (15625000ns) and should be used whenever the system is idle. If the timer resolution is increased, processor power management technologies may not be effective. The timer resolution may be increased due to multimedia playback or graphical animations.
Current Timer Resolution (100ns units)10000
Maximum Timer Period (100ns units)156001



This means my machine is currently with a timer of 1ms (non default value)


The problem of having this setting is manly the power consumption that consumes more 25%.

In systems running under battery it can be a lot.


You can actually check wich application is requesting that interval, in my case...chrome:



Platform Timer Resolution:Outstanding Timer Request
A program or service has requested a timer resolution smaller than the platform maximum timer resolution.
Requested Period10000
Requesting Process ID2788
Requesting Process Path\Device\HarddiskVolume3\Program Files (x86)\Google\Chrome\Application\chrome.exe



If you need to develop an application with this requirement please check the oficial msft documentation:

http://msdn.microsoft.com/en-us/windows/hardware/gg463266.aspx



As other end if you need to change the timer (debug proposes for example) but don´t have access to the code you can simply install a third party application that actually does that.... for examle chrome (when running flash) or x-lite (voip phone)...








Other links regarding clock performance and other settings related with bcdedit and HPET:


Alguns links



Maquina IBM com problemas de performance que recomendam activar o settings:



Detalhes do comando:




Outros







Friday, February 22, 2013

Changing the outlook 2013 contact card to previous version

Changing the outlook 2013 contact card to previous version



Copy the following text to a notepad, save it as outlook.reg and run it.





Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\15.0\common\contactcard]
"TurnOnLegacyGALDialog"=dword:00000001







To revert, go to registry and change the TurnOnLegacyGALDialog value to 0

The specified server cannot perform the requested operation


When trying to access from a machine to other is giving the error:


The specified server cannot perform the requested operation



Go to destination machine > start > run > services.msc > restart the "server" service