ADSI Notes - Diogo Lopes

Search

Search IconIcon to open search

Lecture 11 - Tuning (conclusion)

Last updated Apr 18, 2023

Slides

# MORE TUNING

# Hardware and OS tuning

# Threads

Giving higher/lower priority to some transactions can backfire

# Database Buffer

Goal is Logical Reads without physical action

Assuming OS paging and page replacements are low

Experiment with full table scan

Suddenly the WHOLE TABLE can fit in memory. Beyond this point, you dont need more buffer size (for this query)

# Filesystem

Size of disk chunks allocated at one time

Usage factor of disk pages

Experiment with full table scan

Pre-fetching pages from disk

# RAID Levels

# Database log

# Temporary Files

# Data and index files

# Controller Cache

Disk controllers have memory that servers as cache

Experiments with write-back mode

# Hardware Configuration

# Database monitoring / troubleshooting

# Producer-consumer hierarchy

# Performance Problems

# Systematic Approach: Three Questions

# 1. Are critical queries being served in the most efficient manner?

# 2. Are database subsystems making optimal use of resources?

# 3. Are there enough primary resources for the expected workload?

# Critical Query Monitoring

# Routine Monitoring

# Monitoring Tools

# Investigating High-Level Consumers

  1. Identify the critical queries
    • Use Event Monitor to find end-of-statement with execution measures

  1. Analyze the execution plan
    • Use Query Plan Explainer to analyze the relative cost of each operation

In the execution plan, pay attention to:

  1. Profile the execution
    • Use Performance Monitor to analyze duration and resource consumption

Duration involves 3 indicators:

Two common scenarios

# Investigating Intermediate Resources/Consumers

  1. Disk subsystem
    • A table should be stored contiguously in a physical disk
      • Avoid free space between records (data fragmentation)
    • Table records should be stored in their correct order
      • Avoid records out of place (row displacement)
    • Periodic file reorganization may be necessary

  1. Buffer manager
    • Two main performance indicators to monitor
      • Hit ratio – percentage of times that requested page is already in buffer
      • Number of free pages – how much space is left in the buffer
    • In SQL Server, these and other metrics can be obtained from system views

  1. Locking subsystem
    • Useful indicators
      • Average lock wait time
      • Number of locks on wait
      • Number of deadlocks or timeouts
    • SQL Server provides comprehensive wait statistics through system views

  1. Logging subsystem
    • Useful indicators
      • Number of log waits – ensure log can keep up with transactions
      • Log expansions or log archives – due to lack of space
      • Log cache hit ratio – analogous to buffer cache hit ratio
    • Log waits > 0 means transactions are being held due to log writes

# Investigating Primary Resources

  1. CPU
    • Main indicator
      • Percentage of utilization
    • Use OS task manager to monitor CPU utilization
    • Identify whether processes are database or non-database related
    • Check CPU utilization of system (OS) processes in idle state

  1. Disks
    • Main indicators
      • Average size of the waiting queue
      • Average time taken to service a request
      • Bytes transferred per second
    • Disk utilization can be monitored with OS utilities

  1. Memory
    • Some indicators
      • Number of page faults/time
      • Percentage of paging file in use
    • Size of paging/swap file is an indication of how much memory is lacking

Lecture 10 Tuning (continued)