4 Aug

SQL Tip-6 | Use Covering Index to solve key lookup issues

Do you have Key Lookup problem? Key lookup taking most of the query time. then probably this is the best time to know more about covering indexes. Covering Index can solve all key lookup problems. A Non Clustered Index which contains all columns which are referred by a Query (in Select, Where or Join) is called Covering Index.

To know more read Using Covering Index.

Happy Learning 🙂

Thanks,
Sarabpreet Singh Anand
Subscribe now to get latest Tips in your Inbox


23 Jul

SQL Tip-3 | Don’t Shrink your Database

You should avoid shrinking your database until and unless it becomes unmanageable. Shrinking is a Resource intensive task, Moreover it introduces high degree of fragmentation which affects performance.

Let’s say you shrink a Database, Now if the data is growing in your database the data\log file will reserve more space by auto-growth (if configured) to meet the new requirements. So it does the same work again, Moreover your data is now fragmented which needs to be fixed by doing maintenance activity.

So, The best way to keep free space manageable in your data\log files is to configure Auto-Growth setting with fixed numbers (size) rather than using Percentage (%) value, this will make the auto-growth predictable and ensure that the growth will not go beyond a certain limit.

Happy Learning 🙂

Thanks,
Sarabpreet Singh Anand
Subscribe now to get latest Tips in your Inbox


18 Jul

SQL Tip-2 | Make Sure the startup type of your SQL Service is Automatic*

I know this one is very basic but in the recent past I noticed a couple of environments where the startup type of SQL Server Agent was set to manual which resulted in lot of issues.

Long story cut short – if your SQL Server is not clustered make sure the startup type is set to Automatic so that services can come online after a system reboot. Always use SQL Server Configuration Manager to change any property (including startup type) for any SQL related service.

Incase your SQL Server is clustered its better to keep the startup mode to Manual so that cluster service can take a decision & start the relevant node’s service based on Quorum.

 

Thanks,
Sarabpreet Singh Anand
Subscribe now to get latest Tips in your Inbox


17 Jul

SQL Tip-1 | Don’t forget to recycle your SQLServer ErrorLog

Many a times I’ve seen that DBAs forget to recycle the ErrorLog of their critical SQLServers. Now I also understand that SQLServer Error Log is very important & can help you troubleshoot many issues so in theory there is nothing wrong with a large Error Log but at times this could be very frustrating.

Let’s assume you are trying to resolve a severity case and already under pressure – giving updates to n number of people on a Bridge Call, handling multiple pings from Higher management\Clients and at the same time making sure you resolve the issue within your SLA.

Now between all of this, you need to get some info from your SQL Server error log, you issue the command sp_ReadErrorLog and wait for your log to get loaded and then it keeps on loading which takes 3-4 minutes to load. I am sure you won’t be able to afford this wait, obviously you can also open the file in Notepad but that will also take some time depending on the size of file & you must be on the same server and also need to locate the folder.

Since SQL Server will recycle Error Log only at the time of starting the service until and unless you’ve recycled it explicitly. The best option would be to recycle the errorlog manually on a certain interval (based on the usage & growth rate) .

You can use any one out of the two below mentioned commands in order to recycle Error Log.

sp_cycle_errorlog

or

DBCC ErrorLog

This command will just recycle the errorlog of your SQL Server without any restart, which means if you are recycling your errorlog every 7 days – you’ll be having a fresh errorlog every 7th day without any downtime and your last errorlog will be archived & renamed to ErrorLog.1

Note: Make sure you also increase the log retention limit before recycling your errorlogs, To know more read: Do you know you can increase number of archived Errorlogs

Thanks,
Sarabpreet Singh Anand
Subscribe now to get latest Tips in your Inbox