Category: Performance Tuning
-
Make delete operation fast using CTE.
–drop table t1 create table t1 (a int primary key, b char (100)) declare @i int set @i=1 SET NOCOUNT ON while (@i<100000) begin insert into t1 values (@i,’x’); set @i=@i+1 end ———————————————————- ———————————————————– set statistics io on set statistics time on delete from t1 where a in (select top (10000) a from t1 order by a); set statistics time off set statistics io off ———————————————————– set statistics io on set statistics time on ;with d as ( select top (10000) a from t1 order by a ) delete from d; set statistics time off set statistics io off
//
-
Why are spids in suspended state.
SELECT es.session_id AS session_id ,COALESCE(es.original_login_name, ”) AS login_name ,COALESCE(es.host_name,”) AS hostname ,COALESCE(es.last_request_end_time,es.last_request_start_time) AS last_batch ,es.status ,COALESCE(er.blocking_session_id,0) AS blocked_by ,COALESCE(er.wait_type,’MISCELLANEOUS’) AS waittype ,COALESCE(er.wait_time,0) AS waittime ,COALESCE(er.last_wait_type,’MISCELLANEOUS’) AS lastwaittype ,COALESCE(er.wait_resource,”) AS waitresource ,coalesce(db_name(er.database_id),’No Info’) as dbid ,COALESCE(er.command,’AWAITING COMMAND’) AS cmd ,sql_text=st.text ,transaction_isolation = CASE es.transaction_isolation_level WHEN 0 THEN ‘Unspecified’ WHEN 1 THEN ‘Read Uncommitted’ WHEN 2 THEN ‘Read Committed’ WHEN 3 THEN ‘Repeatable’ WHEN 4 THEN ‘Serializable’ WHEN 5 THEN ‘Snapshot’ END ,COALESCE(es.cpu_time,0) + COALESCE(er.cpu_time,0) AS cpu ,COALESCE(es.reads,0) + COALESCE(es.writes,0) + COALESCE(er.reads,0) + COALESCE(er.writes,0) AS physical_io ,COALESCE(er.open_transaction_count,-1) AS open_tran ,COALESCE(es.program_name,”) AS program_name ,es.login_time FROM sys.dm_exec_sessions es LEFT OUTER JOIN sys.dm_exec_connections ec ON es.session_id = ec.session_id LEFT OUTER JOIN sys.dm_exec_requests er ON es.session_id = er.session_id LEFT OUTER JOIN sys.server_principals sp ON es.security_id = sp.sid LEFT OUTER JOIN sys.dm_os_tasks ota ON es.session_id = ota.session_id LEFT OUTER JOIN sys.dm_os_threads oth ON ota.worker_address = oth.worker_address CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) AS st where es.is_user_process = 1 and es.session_id <> @@spid ORDER BY es.session_id
//
-
SQL Server Black Box Analysis
“SQL Server Black Box Analysis” script give you a MRI report of SQL Server. Haha ha… Script… create table #ServerStats (create_time datetime,component_type sysname,component_name sysname, state int,state_desc sysname, data xml) insert into #ServerStats execute sp_server_diagnostics — Overview — Note: this events component will always show a status of unknown select create_time as “Date”, component_name as “Component”, state_desc as “Status” from #ServerStats — System select ‘System’ as “System”, data.value(‘(/system/@systemCpuUtilization)[1]’,’bigint’) as “System CPU”, data.value(‘(/system/@sqlCpuUtilization)[1]’,’bigint’) as “SQL CPU”, data.value(‘(/system/@nonYieldingTasksReported)[1]’,’bigint’) as “Non-yielding Tasks”, data.value(‘(/system/@pageFaults)[1]’,’bigint’) as “Page Faults”, data.value(‘(/system/@latchWarnings)[1]’,’bigint’) as “LatchWarnings” from #ServerStats where component_name like ‘system’ — Memory select ‘Memory’ as “Memory”, data.value(‘(/resource/memoryReport/entry[@description=”Working…
//
-
Delete vs Truncate
Its a common interview question which people like to ask to know your understanding on RDMS concepts. I too few times encountered the question in interviews. Pleases don’t ask me interview result. Haha ha… DELETE: 1. DELETE is a DML Command. 2. DELETE statement is executed using a row lock, each row in the table…
//
-
DBCC IND
The DBCC IND statement takes three parameters like this: DBCC IND(0,’dbo.SalesOrderDetailList’,1); First parameter is the database id. If you pass in 0 here, the current database is used. Second parameter is the table name in quotes. You can also pass in the object_id of the table instead of the quoted name like this: DBCC IND(0,1797581442,1); Third parameter is the index_id. There is an optional fourth parameter that…
//
-
SQL Server VSS Writer Service
Microsoft built the capability into windows allowing files to be backed up to disk while other programs are using those files. The VSS Servicer interacts with the Windows Volume Shadow Copy service (VSS), allowing files that are in use, such as SQL Server data files, to be copied (or backed up) without stopping all other…
//
-
SQL Server Architecture Diagram
Hey guys, In this blog I am going to explain you about SQL Server Architecture Diagram In almost every SQL DBA interview, this is the question which thrown as a hard ball from interviewer. Below is high level SQL Server Architecture Diagram which is hard to explain in telephonic interview as well as face to…
//
-
DBA Worries Continued DBMS Concepts DBMS Concepts DBMS Concepts L1 DBA Monitoring My SQL Performance Tuning PostgreSQL SQL Server
SQL Server Memory Architecture
There are four major components of SQL memory architecture… 1. Memory Broker2. Memory Object3. Memory Clerk4. Memory Node In short, BOCN. (For remember it “Boy Of Cartoon-Network”) 1. Memory Broker Purpose of Memory Broker is to provide a centralized mechanism to distribute/control memory the allocation made by each component in SQL Server. Note: Memory brokers do…
//
Search
Categories
- Azure (7)
- About Us (1)
- Azure SQL Database (6)
- My SQL (53)
- About Us (1)
- DBMS Concepts (20)
- Handbook (1)
- MySQL Architecture (19)
- MySQL Basics (29)
- MySQL L1 (14)
- Oracle (34)
- PostgreSQL (37)
- About Us (1)
- DBMS Concepts (21)
- PG Hand Book (1)
- pg_ High Availability (4)
- pg_Backup (4)
- pg_basic (11)
- SQL Server (132)
- About Us (1)
- Azure SQL Database (4)
- Backup and Recovery (17)
- Backup Tools for SQL Server (3)
- DBA Worries Continued (27)
- DBMS Concepts (28)
- High Availability (12)
- Installation and Configuration (23)
- L1 DBA (59)
- Monitoring (17)
- Performance Tuning (29)
- Power Shell Script (6)
- Security (12)
- SQL DBA Hand Book (2)
- SQL Scripting (16)
- SQL Server Reporting Services (2)
- Uncategorized (3)