+ All Categories
Home > Documents > Agenda for Today Do Chapter 14 Final Project Review for Final.

Agenda for Today Do Chapter 14 Final Project Review for Final.

Date post: 01-Jan-2016
Category:
Upload: monica-fisher
View: 214 times
Download: 0 times
Share this document with a friend
Popular Tags:
41
Agenda for Today Do Chapter 14 Final Project Review for Final
Transcript
Page 1: Agenda for Today Do Chapter 14 Final Project Review for Final.

Agenda for Today

Do Chapter 14 Final Project Review for Final

Page 2: Agenda for Today Do Chapter 14 Final Project Review for Final.

Monitoring and optimization

Monitoring is important for peak performance and activity

Optimize database performance. Choices are Use Windows monitoring tools like

System Monitor, Task Manager etc. Use SQL Server monitoring tools like

SQL Profilers, Enterprise Manager etc.

Page 3: Agenda for Today Do Chapter 14 Final Project Review for Final.

Optimization

Goals– Optimizing response time– Optimizing throughput– Maximizing availability

What to watch– Database, log, and file sizes– Data consistency issues– User activity– Server performance

Page 4: Agenda for Today Do Chapter 14 Final Project Review for Final.

Performance bottlenecks

Hardware bottlenecks– Disk throughput– Memory usage– Processor usage

SQL Server bottlenecks– Locking conflicts– Resource contention– tempdb activity

Page 5: Agenda for Today Do Chapter 14 Final Project Review for Final.

Key factors

SQL Server configuration and activity Database design and implementation End-user applications Network throughput Server hardware Server operating system

Page 6: Agenda for Today Do Chapter 14 Final Project Review for Final.

Monitoring Tools

System Monitor Task Manager SQL Profiler Query Analyzer Enterprise Manager DBCC commands

Page 7: Agenda for Today Do Chapter 14 Final Project Review for Final.

Using System Monitor

Gathering baseline values Monitoring Windows NT/Windows

2000 counters Isolating bottlenecks Comparing server performance Monitoring critical resources

Page 8: Agenda for Today Do Chapter 14 Final Project Review for Final.

System Monitor - continued

System Monitor includes Performance Objects which

correspond to hardware resources - Table 14-1 has more info

Counters that are data items with specific information on a component

Instances are objects of the same type like databases, hard disks etc

Page 9: Agenda for Today Do Chapter 14 Final Project Review for Final.

System Monitor

Page 10: Agenda for Today Do Chapter 14 Final Project Review for Final.

Performance counters

Page 11: Agenda for Today Do Chapter 14 Final Project Review for Final.

Memory Object Counters

Memory:Available Bytes Memory:Pages/sec Process:Page Faults/sec Process:Working Set SQLServer:Buffer Manager:Buffer

Cache Hit Ratio SQLServer:Buffer Manager:Total

Pages More info in Table 14-7

Page 12: Agenda for Today Do Chapter 14 Final Project Review for Final.

I/O Object Counters

PhysicalDisk:% Disk Time PhysicalDisk:Avg. Disk Queue Length PhysicalDisk:Current Disk Queue

Length Memory:Page Faults/sec SQLServer:Buffer Manager:Page

Reads/sec SQLServer:Buffer Manager:Page

Writes/sec Table 14-8

Page 13: Agenda for Today Do Chapter 14 Final Project Review for Final.

Processor Object Counter

Processor:% Processor Time Processor:% Privileged Time Processor:% User Time System:% Total Processor Time System:Context Switches/sec System:Processor Queue Length More in Table 14-9

Page 14: Agenda for Today Do Chapter 14 Final Project Review for Final.

Event Viewer

Event Viewer logs– Security log– System log– Application log

Page 15: Agenda for Today Do Chapter 14 Final Project Review for Final.

SQL Profiler

Very Important Monitoring Tool Primarily used to monitor stored

procedures, connections,SQL batches Uses a number of filters to isolated the

problem Profiler uses what called a trace to

capture SQL Server events The trace can be paused and replayed Events that can be monitored are

listed in Table 14-2

Page 16: Agenda for Today Do Chapter 14 Final Project Review for Final.

Trace General properties

Page 17: Agenda for Today Do Chapter 14 Final Project Review for Final.

Trace Events properties

Page 18: Agenda for Today Do Chapter 14 Final Project Review for Final.

Trace Data Columns properties

Page 19: Agenda for Today Do Chapter 14 Final Project Review for Final.

Trace Filters properties

Page 20: Agenda for Today Do Chapter 14 Final Project Review for Final.

Standard templates (Profiler)

SQLProfilerSP_Counts SQLProfilerStandard SQLProfilerTSQL SQLProfilerTSQL_Duration SQLProfilerTSQL_Grouped SQLProfilerTSQL_Replay SQLProfilerTSQL_SPs SQLProfilerTuning

Page 21: Agenda for Today Do Chapter 14 Final Project Review for Final.

Class Assignments

Page 532 Page 537 Take a break

Page 22: Agenda for Today Do Chapter 14 Final Project Review for Final.

Other SQL Server tools

System stored procedures Table 14-4 has more info. Sp_who

and sp_lock are important ones DBCC commands These act as the “database

consistency checker” for SQL Server Table 14-5 has more info on these

commands

Page 23: Agenda for Today Do Chapter 14 Final Project Review for Final.

DBCC commands

DBCC HELP Help on syntax for DBCC commands syntax:

DBCC HELP ('dbcc_statement')

DBCC CHECKALLOC Checks the allocation and use of all

pages in the specified database syntax: DCC CHECKALLOC ('database'[, NOINDEX |

REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD]

Page 24: Agenda for Today Do Chapter 14 Final Project Review for Final.

DBCC commands

DBCC CHECKDB syntax:DBCC CHECKDB ('database'[, NOINDEX |

REPAIR_ALLOW_DATA_LOSS | REPAIR_FAST | REPAIR_REBUILD]

)

[WITH [ALL_ERRORMSGS | NO_INFOMSGS]

[, TABLOCK][, ESTIMATEONLY][, PHYSICAL_ONLY]

DBCC CHECKFILEGROUP syntax:DBCC CHECKFILEGROUP ('filegroup'|filegroup_id

[, NOINDEX] )

[WITH [ALLERRORMSGS | NO_INFOMSGS][, TABLOCK][,ESTIMATEONLY]]

Page 25: Agenda for Today Do Chapter 14 Final Project Review for Final.

Current activity and Locking

Page 26: Agenda for Today Do Chapter 14 Final Project Review for Final.

Process ID - all current conn

Page 27: Agenda for Today Do Chapter 14 Final Project Review for Final.

Locks / Process ID - SPID’s

Page 28: Agenda for Today Do Chapter 14 Final Project Review for Final.

Locks / Object - info on Locks

Page 29: Agenda for Today Do Chapter 14 Final Project Review for Final.

Issuing locks

Locking ensures correct updates SQL Server can issue locks for:

– A row identifier (RID), locking a single row in a table

– A table, which locks all data rows and indexes

– A database, which is used when restoring a database

– A page, locking an 8-KB data or index page

– An extent, locking a contiguous group of pages during space allocation

Page 30: Agenda for Today Do Chapter 14 Final Project Review for Final.

Lock types

Basic locks– Shared– Exclusive

Special locks– Intent– Intent exclusive– Shared with intent exclusive– Update– Schema– Bulk update

Page 31: Agenda for Today Do Chapter 14 Final Project Review for Final.

Lock information – T-SQL

Use sp_who to retrieve information about users and processes.

sp_who ['login_name']

Use sp_lock to view lock information. sp_lock [spid]

Page 32: Agenda for Today Do Chapter 14 Final Project Review for Final.

Clearing deadlocks

1. The deadlocked transaction is rolled back.

2. The application initiating the transaction is notified of the rollback with a message number 1205.

3. The transaction’s current request is cancelled.

Page 33: Agenda for Today Do Chapter 14 Final Project Review for Final.

Joining tables

Joins are created through instructions in the SELECT clause.

Joins connect two or more tables by using a join operator.

Joins exist only for the duration of that query.

Joins do not make changes to any database tables.

Page 34: Agenda for Today Do Chapter 14 Final Project Review for Final.

Join columns

The order of columns displayed is the order of columns chosen in the SELECT clause, with * choosing all columns in the order of the base table.

All tables being joined must be named in the FROM clause.

Create aliases for table names to reduce typing and make queries easier to read.

If NULLs are allowed in either connecting column, matches are not made with other NULLs.

Page 35: Agenda for Today Do Chapter 14 Final Project Review for Final.

Types of Joins

INNER JOIN OUTER JOIN

– LEFT OUTER JOIN– RIGHT OUTER JOIN

Page 36: Agenda for Today Do Chapter 14 Final Project Review for Final.

Inner joins

Only those rows that satisfy the join condition are displayed in the result.

Inner join syntax:SELECT select_list

FROM table_or_view

[INNER] JOIN table_or_view

ON (join_condition)

Page 37: Agenda for Today Do Chapter 14 Final Project Review for Final.

Outer joins

LEFT OUTER JOIN (LEFT JOIN) – All rows from the left table named in the

LEFT OUTER JOIN clause are returned in the result set.

LEFT JOIN syntax:SELECT select_list

FROM table_or_view

LEFT [OUTER] JOIN table_or_view

ON (join_condition)

Page 38: Agenda for Today Do Chapter 14 Final Project Review for Final.

Outer joins

RIGHT OUTER JOIN (RIGHT JOIN) – All rows from the right table named in the

RIGHT OUTER JOIN clause are returned in the result set.

RIGHT JOIN syntax:SELECT select_list

FROM table_or_view

RIGHT [OUTER] JOIN table_or_view

ON (join_condition)

Page 39: Agenda for Today Do Chapter 14 Final Project Review for Final.

Outer joins

FULL OUTER JOIN (FULL JOIN) – All rows from both tables are returned by

a FULL OUTER JOIN clause.

FULL JOIN syntax:SELECT select_list

FROM table_or_view

FULL [OUTER] JOIN table_or_view

ON (join_condition)

Page 40: Agenda for Today Do Chapter 14 Final Project Review for Final.

Class Assignments

Page 543 Try the Join examples included in the

word document Use Query Analyzer for this Take a break

Page 41: Agenda for Today Do Chapter 14 Final Project Review for Final.

Final Test

Next week (5:30 - 7:30) Chapter 8-14 Open Book Open Notes Straight Scale >90 = A, >80 = B and so on In class material (slides and handout) 100 Questions (multiple choice) 200 points Any questions?


Recommended