1. Trang chủ
  2. » Công Nghệ Thông Tin

The Real MTCS SQL Server 2008 Exam 70/432 Prep Kit- P120 pptx

5 77 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 130,73 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

start sQL server configuration Manager from start > Programs > Microsoft sQL server 2008 > configuration Tools.. start sQL server Management studio.. Guide to the DYNAMIC Management Vie

Trang 1

ExErcisE 13.2

This exercise will demonstrate how to enable a trace flag to proactively

monitor for deadlocks within sQL server:

1 start sQL server configuration Manager from start > Programs >

Microsoft sQL server 2008 > configuration Tools.

2 select sQL server services from the left-hand pane.

3 Locate the sQL server instance where the trace flag is to be

added in the right-hand pane.

4 Double-click the sQL server service.

5 click the Advanced tab.

6 Locate the startup parameters field.

7 Move cursor to the right-most position.

8 Add a semicolon and T1222 to the end of the string—the

command should finish up something like this:

-dc:\Program Files\Microsoft sQL server\MssQL.1\MssQL\DATA\

master.mdf;-ec:\Program Files\Microsoft sQL server\MssQL.3\

MssQL\LOG\ErrOrLOG;-lc:\Program Files\Microsoft sQL server\

MssQL.3\MssQL\DATA\mastlog.ldf; -T8029; T1222

9 click OK.

10 restart the sQL server service for the trace flag to take effect.

To view the output of the traceflag—that is, to monitor whether any

deadlocks have occurred:

1 start sQL server Management studio.

2 Expand the Management folder.

3 Expand sQL server logs.

4 Double-click the log file.

Alternately, run sp_readerrorlog from a query window to read the

contents of the active error log.

Trang 2

Guide to the DYNAMIC

Management Views (DMVs)

DMVs are almost certainly the single most useful tool for troubleshooting and performance tuning for SQL Server databases DMVs and DYNAMIC

Management Functions (DMFs) provide Administrators with a simple yet powerful insight into the workings of SQL Server and hardware resources (disk, memory, CPU) There were 89 DMVs introduced to SQL Server 2005 and 47 new DMVs released with SQL Server 2008 These can be grouped in two broad types:

Server Scoped (require VIEW SERVER STATE permission on the server)

Database Scoped (require VIEW DATABASE STATE permission on the

database) DMVs can be categorized as follows (there are others that don’t fit into these categories):

Common Language Runtime

Cryptographic

Database Mirroring

Execution

Extended Events

Filestream

Full-Text Search

Index

I/O

Query Notifications

Replication

Service Broker

SQL Server Operating System

Transaction

As mentioned in the Profiler section earlier in this chapter, there’s a SQL trace running continuously in the background and cycling itself while SQL Server is running This trace gathers the data used by the DMVs; you should be aware of those that provide snapshot information and others that provide data cumulatively

Trang 3

since the last service restart The trace data is not persisted anywhere within SQL

Server, although this is possible (covered in the Performance Data collection, later)

DMVs provide information that often could be reached only by querying

meta-data or system tables SQL Server administrators often like a real-time view of current server activity, and they might use the Activity Monitor within Management Studio,

or if they have a background with SQL Server 2000 or earlier They’ll probably use

SP_WHO or SP_WHO2—both provide session level activity view There are,

how-ever, a couple of DMVs in Table 13.4 that provide this information plus much more

DYNAMIC Management View Purpose

sys.dm_exec_requests Provides information about a request

currently executed by SQL Server Sys.dm_exec_sessions An overview of all current sessions (SPIDs)

within SQL Server

Table 13.4 Using DMVs to View Current Activity within SQL Server

It’s easy to SELECT all data within a DMV, however there are great

opportuni-ties to write useful queries to interrogate DMVs One such example is sys.dm_db_

index_physcial_stats This DMV shows the level of index fragmentation In previous

versions this was available from the DBCC SHOWCONTIG command, however

this was very intensive for Disk IO, and the results were cumbersome and difficult

to manipulate without significant effort The following example shows a query that

categorizes index fragmentation as High (more than 30%), Medium (less than 30%),

and Low (less than 5%), ordering the results by greatest fragmentation first since this

is where we should pay most attention:

SELECT

OBJECT_NAME(indstat.object_id, indstat.database_id) AS obj_name,

QUOTENAME(sysind.name) [index_name],

CASE

WHEN avg_fragmentation_in_percent < 5 THEN 'LOW'

WHEN avg_fragmentation_in_percent < 30 THEN 'MEDIUM'

ELSE 'HIGH'

END as frag_level,

indstat.*

Trang 4

AS indstat

INNER JOIN sys.indexes sysind ON indstat.object_id = sysind.object_id AND indstat.index_id = sysind.index_id

ORDER BY avg_fragmentation_in_percent DESC

The output of the sys.dm_db_index_physcial_stats can be used as the input to

an index maintenance job In this scenario it is possible to build a SQL Server Agent job that takes action based on the output of the sys.dm_db_index_physcial_ stats, such as an index reorganize (for indexes with low or medium fragmentation)

or rebuilding indexes (for those indexes with heavy fragmentation)

Extending the idea of good indexing maintenance, SQL Server can also suggest indexes that would help improve query performance This information is provided by

a group of DMVs, the most useful of which is sys.dm_db_missing_index_details Using the output from this DMV, we can generate the CREATE INDEX statement

to add the new index and improve performance! However, there numerous limitations

of the missing indexes feature; for example, it doesn’t consider the cost of maintaining

an index and it doesn’t specify an order for columns to be used in the index

There are DMVs such as sys.dm_os_∗ that reflect aspects of the SQL Server Operating System and can be useful barometers for understanding more about SQL Server Internals, system memory consumption, requirements, and the like The follow-ing query uses the sys.dm_exec_query_stats to provide the top 10 queries consumfollow-ing most CPU:

SELECT TOP 10

SUM(qrystat.total_worker_time) AS Total_CPU_Time,

SUM(qrystat.execution_count) AS Number_of_Executions,

COUNT(*) as Number_of_Statements,

qrystat.plan_handle

FROM

sys.dm_exec_query_stats qrystat

GROUP BY qrystat.plan_handle

ORDER BY sum(qrystat.total_worker_time) DESC

Trang 5

ExERCISE 13.3

Take a look at the following DMVs to become familiar with the contents:

sys.dm_exec_requests

sys.dm_exec_sessions

sys.dm_exec_sql_text

sys.dm_exec_query_stats

sys.dm_os_wait_stats

sys.dm_db_index_usage_stats

sys.dm_db_index_operational_stats

sys.dm_db_missing_index_details

Partitioning

Organizations collect more data and retain data for longer than ever before

The phenomenal growth of the storage manufacturing industry over the past

10 years is a testament to continually increasing data collection Given adequate

capacity, storing large quantities of data within SQL Server is no big problem, until

we need to retrieve some data or perform any maintenance New challenges arise

from retrieving single rows or range searches of multiterabyte databases, while

maintaining good response times

Partitioning was first available in SQL Server 7.0, although in different versions

this application logic was required to determine the partition holding a specific row

In SQL Server 2000 it was possible to define a view that unified the data and in

SQL Server 2005 table partitions were completely transparent to applications SQL

Server 2008 Enterprise edition provides the next generation of table and index

partitioning, which introduces a round-robin thread model to satisfy queries accessing

multiple partitions Additionally, SQL Server 2008 includes new level of lock

escalation, which means locks can escalate from row or page locks to partition locks

This differs from SQL Server 2005, where row or page locks could be escalated

directly to table locks

Horizontal Partitioning

Horizontal Partitioning involves dividing a large table into a number of smaller

tables, each containing all columns for a subset of rows Dividing rows into separate

tables means each table is much smaller and access times are typically more efficient,

Ngày đăng: 07/07/2014, 00:20

TỪ KHÓA LIÊN QUAN