sql server tips from the field

42
SQL Server Tips From The Field Three Things IT Leaders Need to Know… Web: www.sqlwatchmen.com Email: [email protected] Twitter: @SQLMurph Jim Murphy CEO SQLWatchmen, LLC.

Upload: joanna-cheshire

Post on 11-Feb-2017

44 views

Category:

Technology


2 download

TRANSCRIPT

SQL Server Tips From The FieldThree Things IT Leaders Need to Know…

Web: www.sqlwatchmen.comEmail: [email protected]: @SQLMurph

Jim MurphyCEOSQLWatchmen, LLC.

1. Database Performance and Speed Matter

2

[ ]

1. Database Performance and Speed Matter

3

2. Backups and Disaster RecoveryPlans are not all created equal[ ]

[ ]

1. Database Performance and Speed Matter

4

2. Backups and Disaster RecoveryPlans are not all created equal[

3. High Availability / Disaster Recovery (HA/DR) is a set of tools used for Proactive Disaster Protection

][ ]

[ ]

Who is SQLWatchmen?

● DBA Services – tuning, disaster recovery

planning, maintenance

● SQL Programming - views, SPs, triggers

● Integration Services - SSIS for trying

systems together

● Reporting - SSRS for custom analytics to

fill business needs

5

● Local to Austin

● Can serve as Remote / Fractional DBAs

● SQL Server Specialists (We work alongside

general tech consulting firms)

● Compliance (HIPPA, SOX, SOC2)

How can we assist you?

Database Performance and Speed Matter66

7

1. Identifying the problem & why you should care

Problem: • The database is the foundation of the entire

application or corporate stack. If the database is slow…

8

1. Identifying the problem & why you should care

Problem: • The database is the foundation of the entire

application or corporate stack. If the database is slow…

9

1. Identifying the problem & why you should care

Problem: • The database is the foundation of the entire

application or corporate stack. If the database is slow…

• … Customers frustrated. Hurts reputation• … Employees frustrated. Hourglasses waste time

10

2. There are many reasons for databases toget slower over time (i.e. bottlenecks)

Cause: • Bottleneck is usually:• CPU• Memory• Disk IO• Network

11

3. Slow-downs happen when queriesare inefficient

●More users●More data volume●More complex queries

12

4. Which solution is faster & cheaper?

Solution:

A. Upgrade hardware and migrate.

B. Figure out which queries are the biggest resource hogs and make adjustments.

That doesn’t sound cheap!

So offending queries use far fewer resources.

13

5. Performance Tuning gets to the root cause of slowdowns

●Benefit = Lower Cost●Benefit = Tuning is more effective at improving

speed & performance

14

● SQL Server processes query; makes Execution Plan● Execution Plan cached; remembered next time● Ad hoc (one-time, on-demand) queries can fill up the cache with lots of these (inefficient)

● Stored Procedures reuse pre-cached Execution Plans (more efficient)

6. Understanding how Queries are processed

15

DemoMeasuring results with Perfmon:

MSSQL:SQL Statistics -> Batch Requests/sec

Backups and Disaster Recovery Plans are not all created equal

16

17

1. Identifying the problem & why you should care

●What’s the difference between a backup and a disaster recovery plan?

●Backup Plan = Backups work●Disaster Recovery Plan = Data recovered

18

2. There are lots of different technologies youmight consider using:

●VM Snapshots●SAN Replication●Volume Shadow Copy●VEEAM●SQL Dump Files – Microsoft recommended

19

3. Transaction Log explained

• Diary of data changes• Diary won’t ‘clear’ (Truncate) and be reused until it is

backed up (if database in FULL mode)• T-Log (.LDF file) will grow and grow until drive fills up• DANGER! Full drive = corrupt database (and also bring it

offline)!

20

4. Transaction Log explained (continued)

• FULL backup hurts performance• Saves off all data pages with valid data on it• Locks tables and indexes to access up-to-date data• T-Log backup DOES NOT hurt performance• T-Log is circular in usage. Segments (VLF)• T-Log backup backs up each VLF & “truncates” T-Log• Doesn’t lock tables

21

5. There are also 2 different recovery modes to consider:

SIMPLE• Only non-production• Uses Transaction Log for current

transactions only.• T-Log only grows if a long

transaction with lots of data changes runs.

• No point-in-time recovery (can only recover to most recent FULL or Differential backup).

FULL• Use for all Production databases.• Keeps T-Log as diary for all data

changes until T-Log is backed up (and also ‘replicated’ if an HA/DR technology is configured).

• T-Log will grow until drive is filled if not backed up.

• Can perform point-in-time recovery (restore to an exact millisecond before a disaster so no data is lost).

22

6. An example of Point in Time Recovery

Image Source: https://sqlbak.com/blog/sql-server-backup-and-restore/

23

PRO TIP

If T-Log backup is getting too big, and you can’t backup or shrink

- Switch your Recovery Mode to Simple*[ ]

24

Demo

High Availability / Disaster Recovery (HA/DR)

is a set of procedures and methods used for proactive disaster protection

25

26

1. Identifying the problem & why you should care

Reasons why you might want to consider HA/DR for your company●What does High Availability mean?●What is Disaster Recovery in this context?●What is AlwaysOn?●What are Availability Groups?

27

2. Solutions involve removing the single point of failure

●Clustering - redundant hardware●RAID - redundant individual disks● “Replication” - redundant databases

○ What are the limitations?

28

3. Problems that arise with “Replication”methods

Transactional Replication

MirroringLog Shipping

• No automatic failover.

• Secondary DB is not really Online*.

• Single DB solution.

• Secondary offline while restoring T-Logs.

• Secondary database is not Online.

• Single Mirror/ Secondary only.

• SNAC/Failover Partner in connection string.

What will AlwaysOn Solve?

• No automatic failover.• Major headache.

o Higher administration.

o Republish articles, etc.

o Complicated troubleshooting

29

4. AlwaysOn Solves World Hunger!

…and peace on earth and goodwill toward men.

● Automatic Failover● Multiple Replicas (secondaries) – and readable!

● “Replication” - redundant databases

○ Offload Backups, Reporting, etc.● Availability Groups - assists with using multiple DBs

● Lower administrative costs● Plus more!

30

5. There are a few requirements to consider

●Enterprise Edition●AD for WSFC●Nodes must be in the same domain

31

6. HA, DR, or Both?● Synchronous● Asynchronous

Sync Async

Legend

32

7. Listener (Virtual Network Name)

Node 1 Node 2

DENALI02 DENALI03

VNN

Node 1 Node 2

33

Demo

What’s New in SQL Server 2016?

35

What’s new in 2016?• Columnstore indexes for big data

○ 30x in-memory OLTP speed○ 100x in-memory Columnstore speed

• Query Store – better diagnostics for a DBA• Stretch databases (Auto-archiving)• Always Encrypted (at rest, in motion, cloud)• Temporal DB – track historical changes• Row-level security.• …and a lot more.

SQL Server is beautiful…but it can be a beast[ ]

36

You don’t need new hardware - Tune for Performance[ ]

37

Keep your backups secure.Disaster recovery methods

should be tested![ ]

38

Next Steps

● For another slide deck that delves deeper on SQL backups -

visit http://www.sqlwatchmen.com/contact-us

● To check out if a Database Diagnostic Exam is right for you -

visit http://www.sqlwatchmen.com/services/database-diagnostic-analysis

39

Treated properly, MS SQL Server can contribute a solid foundation to the

efforts of your business ][40

Let us help you, Protect Your Data ][

41

SQL Server Tips From The FieldThree Things IT Leaders Need to Know…

Web: www.sqlwatchmen.comEmail: [email protected]: @SQLMurph

Jim MurphyCEOSQLWatchmen, LLC.

http://www.sqlwatchmen.com/services/database-diagnostic-analysis