Cloud Comparison
Latest Articles
It may look funny but it is true DBA VS TOMATO
I paid around INR150 for 1 KG of Tomato (current market price may differs other states of india or country )
What is the price of 1 KG Tomato in your area?---------------------------------------------------
Tomatoes serve as a source of essential vitamins, minerals, and antioxidants in a diet. They add flavor, texture, and color to various culinary preparations.
In contrast, a DBA's primary function is to design, implement, and manage databases, ensuring data integrity, performance, and availability for organizations or applications relying on data storage and retrieval.
Tomato helps to improve immunity
DBA helps to improve Database Performance
"Always On Availability Groups: Essential DBA Scripts for Monitoring and Checking SQL Server High Availability"
Check Availability Group Health:
SELECT
ag.name AS
[Availability Group],
ar.replica_server_name AS [Replica Server],
adc.database_name
AS [Database],
ags.is_local AS
[Is Local],
ags.is_primary_replica AS [Is Primary]
FROM
sys.availability_groups AS ag
INNER JOIN
sys.dm_hadr_availability_replica_states AS ars
ON ag.group_id
= ars.group_id
INNER JOIN
sys.dm_hadr_availability_replica_cluster_states AS arcs
ON
ars.group_id = arcs.group_id
AND
ars.replica_id = arcs.replica_id
INNER JOIN
sys.dm_hadr_database_replica_cluster_states AS adc
ON
arcs.group_id = adc.group_id
AND
arcs.replica_id = adc.replica_id
INNER JOIN
sys.availability_group_listeners AS agl
ON ag.group_id
= agl.group_id
INNER JOIN
sys.dm_hadr_availability_replica_states AS ags
ON
ags.replica_id = ars.replica_id
WHERE
ars.is_local = 1;
This script provides an overview of the availability group
health, including the availability group name, replica server name, database
name, and whether the replica is the primary replica or not.
Check Data Synchronization:
SELECT
ag.name AS
[Availability Group],
d.name AS
[Database],
drs.synchronization_state_desc AS [Synchronization State],
drs.synchronization_health_desc AS [Synchronization Health]
FROM
sys.availability_groups AS ag
INNER JOIN sys.dm_hadr_database_replica_states
AS drs
ON ag.group_id
= drs.group_id
INNER JOIN
sys.databases AS d
ON
drs.database_id = d.database_id;
This script shows the synchronization state and health of
the databases within the availability group. It provides information on whether
the data is synchronized or if there are any synchronization issues.
Check Availability Group Listener:
SELECT
ag.name AS
[Availability Group],
agl.dns_name AS
[Listener DNS Name],
agl.port AS
[Listener Port],
agl.state_desc AS
[Listener State]
FROM
sys.availability_groups AS ag
INNER JOIN
sys.availability_group_listeners AS agl
ON ag.group_id
= agl.group_id;
This script displays the availability group name, listener
DNS name, port, and the state of the availability group listener.
Check Failover Readiness:
SELECT
ag.name AS
[Availability Group],
drs.database_id AS
[Database ID],
d.name AS
[Database],
drs.is_failover_ready
AS [Is Failover Ready]
FROM
sys.availability_groups AS ag
INNER JOIN
sys.dm_hadr_database_replica_states AS drs
ON ag.group_id
= drs.group_id
INNER JOIN
sys.databases AS d
ON
drs.database_id = d.database_id;
SQL scripts that may be helpful for MS SQL Server DBAs in their daily tasks:
SQL scripts that may be helpful for MS SQL Server DBAs in their daily tasks:
1.Script to Backup a Database:
BACKUP DATABASE [YourDatabaseName]
TO DISK = 'C:\Backup\YourDatabaseName.bak'
WITH INIT, FORMAT, COMPRESSION;
2.Script to Restore a Database:
RESTORE DATABASE [YourDatabaseName]
FROM DISK = 'C:\Backup\YourDatabaseName.bak'
WITH REPLACE, RECOVERY;
3.Script to Check Database Integrity:
DBCC CHECKDB ('YourDatabaseName') WITH NO_INFOMSGS;
Script to Shrink Transaction Log File:
DBCC SHRINKFILE ('YourDatabaseName_log', 1);
SELECT
r.session_id,
r.start_time,
r.status,
r.command,
t.text AS [SQL Text]
FROM
sys.dm_exec_requests r
CROSS APPLY
sys.dm_exec_sql_text(r.sql_handle) t
WHERE
r.status NOT IN
('background', 'sleeping')
ORDER BY
r.start_time DESC;
4..Script to Grant Permissions to a User:
USE [YourDatabaseName]
GO
GRANT SELECT, INSERT, UPDATE, DELETE ON [YourSchema].[YourTable]
TO [YourUserName];
5.Script to Update Statistics for a Table:
USE [YourDatabaseName]
GO
UPDATE STATISTICS [YourSchema].[YourTable];
CLOUD COMPUTING
CLOUD COMPUTING
SQL scripts commonly used by DBAs in production server environments:
Script to
Monitor Blocking Queries:
SELECT
r.session_id,
r.blocking_session_id,
t.text AS [SQL
Text]
FROM
sys.dm_exec_requests r
CROSS APPLY
sys.dm_exec_sql_text(r.sql_handle) t
WHERE
r.blocking_session_id <> 0;
Script to
Monitor Server Performance:
SELECT
[object_name],
[counter_name],
[cntr_value]
FROM
sys.dm_os_performance_counters
WHERE
[object_name] LIKE
'%:SQLServer%'
AND [counter_name]
IN ('Batch Requests/sec', 'Transactions/sec', 'User Connections')
ORDER BY
[object_name],
[counter_name];
Script to
Identify Index Fragmentation:
SELECT
dbschemas.[name] +
'.' + dbtables.[name] AS [Table Name],
dbindexes.[name]
AS [Index Name],
indexstats.avg_fragmentation_in_percent
FROM
sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) AS
indexstats
INNER JOIN
sys.tables dbtables ON dbtables.[object_id] = indexstats.[object_id]
INNER JOIN
sys.schemas dbschemas ON dbtables.[schema_id] = dbschemas.[schema_id]
INNER JOIN
sys.indexes AS dbindexes ON dbindexes.[object_id] = indexstats.[object_id] AND
indexstats.index_id = dbindexes.index_id
WHERE
indexstats.avg_fragmentation_in_percent > 10
ORDER BY
indexstats.avg_fragmentation_in_percent DESC;
Script to Find High CPU Queries:
SELECT TOP 10
total_worker_time/execution_count AS Avg_CPU_Time,
total_worker_time
AS Total_CPU_Time,
execution_count,
creation_time,
last_execution_time,
st.text AS [SQL
Text]
FROM
sys.dm_exec_query_stats
AS qs
CROSS APPLY
sys.dm_exec_sql_text(qs.[sql_handle]) AS st
ORDER BY
total_worker_time/execution_count DESC;
Script to
Check Database Size and Space Usage:
EXEC sp_MSforeachdb '
USE [?];
SELECT
DB_NAME() AS
[Database Name],
(size * 8) AS
[Size (KB)],
FILEGROUP_NAME(data_space_id) AS [Filegroup],
name AS
[Logical Name],
(size * 8 -
FILEPROPERTY(name, ''SpaceUsed'') * 8) AS [Unused Space (KB)]
FROM
sys.master_files
WHERE
type = 0;
';
The Impact of COVID-19: Layoffs in the IT Field 2020
Among the survey respondents, software engineers experienced a 5% job loss. Also, 48% of all the surveyed professionals showed concern about job security. On the other hand, only 31% of software engineers highlighted the issue of job security.
It is important to highlight here that the above software engineering job respondent data is taken from across the industrial spectrum. Engineers and developers working in different sectors may likely face contrasting situations. For instance, software engineers and developers working in the hospitality industry have to experience pay cuts and layoffs.
On the other hand, engineers and developers working on the security side have experienced growth. Their services and products have been in more demand in the last couple of months as workspaces worldwide have become more dependent on technology. In the US alone, the demand for cybersecurity professionals has surged by 65% since April
SQL SERVER 2012,2014,2016,2017 New Features
Each version introduced its own set of new features and enhancements. Here are some notable new features introduced in SQL Server 2012 and SQL Server 2014:
Delayed Durability : This feature allows you to control the durability of transaction commits, improving performance for write-intensive workloads.
Both versions brought new features and improvements to the SQL Server platform. Here are some notable features introduced in SQL Server 2016 and SQL Server 2017:
---SQL Server 2016-----
Stretch Database: This feature allows you to transparently and securely extend your on-premises database to Azure SQL Database, providing cost-effective storage and seamless access to historical data.
Query Store: Query Store provides detailed insights into query performance by capturing query execution plans and statistics, enabling easy identification and resolution of performance regressions.
PolyBase: PolyBase enables you to query and analyze data across relational and non-relational data sources, such as Hadoop, using T-SQL, making it easier to integrate and process big data alongside traditional SQL Server data.
JSON Support: SQL Server 2016 introduced built-in support for storing, querying, and manipulating JSON data, allowing for better integration with modern application development and data interchange formats.
-----SQL Server 2017------
Graph Database Capabilities: SQL Server 2017 introduced support for graph database features, enabling the modeling and querying of complex relationships between data entities, making it suitable for scenarios such as social networks and fraud detection.
Automatic Tuning: This feature leverages machine learning to continuously monitor and optimize query performance by automatically applying performance recommendations, including creating indexes or adjusting query plans.
Resumable Online Index Rebuild: SQL Server 2017 introduced the ability to pause and resume index rebuilding operations, allowing for more flexibility and reduced maintenance windows for large-scale index maintenance.
Adaptive Query Processing: This feature provides intelligent query performance optimization by dynamically adjusting execution plans based on actual runtime statistics, leading to more efficient query processing.
Essential SQL Queries for Database Administrators (DBAs)"
This query can be used to monitor the space usage of each session in the database, helping you identify any sessions that are consuming excessive space.
dbcc sqlperf(logspace):
By executing this command, you can obtain information about the transaction log space usage for each database. It helps you identify if any transaction logs are growing too large and may require management.
xp_fixeddrives:
This query provides information about the fixed drives (hard drives) on the SQL Server machine. As a DBA, you can use this to ensure sufficient disk space is available for the database files and logs.
dbcc showcontig:
Use this command to analyze the fragmentation level of tables and indexes. It helps you identify fragmented objects that might impact performance and allows you to plan for defragmentation or index maintenance.
select * from sys.dm_db_index_physical_stats:
This query returns detailed physical statistics about indexes in a specified table or view. It helps you analyze index fragmentation, identify unused indexes, and optimize the indexing strategy.
select * from sys.dm_exec_requests order by cpu_time:
By running this query, you can monitor the CPU time consumed by different SQL requests, helping you identify resource-intensive queries that may require optimization.
select * from sys.dm_exec_sessions:
This query provides information about active sessions on the SQL Server instance. It allows you to monitor the current connections, identify long-running sessions, and troubleshoot blocking issues.
select * from sys.dm_os_waiting_tasks where session_id > 0:
Use this query to identify the waiting tasks on the SQL Server instance for user sessions. It helps you investigate and resolve blocking and contention issues.
select * from sys.dm_os_wait_stats:
This query retrieves wait statistics at the system level, allowing you to identify the most common waits and potential bottlenecks in the system.
select * from sys.dm_io_virtual_file_stats:
By executing this query, you can monitor the I/O statistics for database files, helping you identify any performance issues related to disk I/O.
select * from sys.dm_os_performance_counters:
This query retrieves performance counter information for the SQL Server instance. It enables you to monitor various server performance metrics such as CPU usage, memory utilization, and disk activity.
I would like to share with you what I have learned and I hope it will be useful for you. _V€€RAKUMAR
Mastering SQL Server
Search This Blog
Mastering SQL Server
Labels
Translate
About Me
Restarting my career from where I left off. With hands-on experience as a Microsoft SQL Server DBA, I have developed skills in database mana...










