database administration & optimization

18
By Shanna Epstein IS 257 September 16, 2008

Upload: wendi

Post on 15-Jan-2016

40 views

Category:

Documents


0 download

DESCRIPTION

Database Administration & Optimization. By Shanna Epstein IS 257 September 16, 2008. Cnet.com. Provides information, tools, and advice to help customers decide what to buy and how to get the most out of technology: News Reviews Downloads. Cnet.com Other Sites. Cnet.com Bnet.com - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Database Administration & Optimization

By Shanna EpsteinIS 257

September 16, 2008

Page 2: Database Administration & Optimization

Cnet.comProvides information, tools, and advice to

help customers decide what to buy and how to get the most out of technology:NewsReviewsDownloads

Page 3: Database Administration & Optimization

Cnet.com Other SitesCnet.comBnet.comZdnet.comGamespot.comTV.comChow

Page 4: Database Administration & Optimization

Job ResponsibilitiesSoftware Engineer for TraxLead team of 2 developersResponsible for development and

maintenance of productSupport Windows serversSupport php websites and SQL Server 2005

databases

Page 5: Database Administration & Optimization

What is Trax?Industry’s most advanced tool for

TrackingAnalyzing Entertainment Data

Consumer Awareness Interest and Purchase Intent Competitive Mindshare Ad campaign effectiveness Audience profiles Editorial coverage

Page 6: Database Administration & Optimization

Data SourcesGamespot (Gamespot Trax)

Gamespot.comGameRankings.comDownload.com

TV (TV Trax)tv.com

MovieTome (Trax coming soon)movietome.com

MP3 – Juke (Trax coming soon)juke.com (coming out soon)

Page 7: Database Administration & Optimization

MetricsAbout 20 totalMost important:

Users/Avg. Daily Users (by Sessions)Page Views (hits of pages)Searches (execute search for a game)New Trackers/Total Trackers (track games in

Favorites)DownloadsVideos

Page 8: Database Administration & Optimization

Data ProcessingStage servers

process heavy jobs at night and early morning data comes from various sources

direct database queries text file feeds xml feeds

replicate to production early in the morningreplicate to development in off hours

Page 9: Database Administration & Optimization

ArchitectureDevelopment

Code: developer PCs (php)Database server: SQL Server2005

Staging (data processing, replication, testing)Windows server, SQL Server 2005, Apache2 servers: Gamespot Trax, TV Trax

ProductionWindows server, SQL Server 2005, Apache2 servers: Gamespot Trax, TV Trax

Page 10: Database Administration & Optimization

Database Maintenance OptimizationJobs scheduled in SQL Server Job Agent consists

of several steps involving:Job status can be retrieved through queries

against the Master dbDBA can be notified of success/failure through

user interface or emails1st step checks whether job already completed

successfully today2nd step checks whether dependent jobs completedLater steps consist of php scripts (read and

process data, send e-mails, etc) and SQL queries

Page 11: Database Administration & Optimization

Controlling Database ProcessesTask Manager on Windows Server

monitors CPU usageSQL Server Activity Monitor - ad hoc monitoring tool

Allows to determine volume and general types of activities

lists user connections , locks, open, and blocked transactions

SQL Query Profiler - query optimizerallows to trace queries for analysis and catch query

bottlenecksLogging

Automatic system error loggingDatabase consists of data and log file

Page 12: Database Administration & Optimization

Optimizing Database PerformanceCaching

Saves frequently used information into an easy to get to area (usually memory)

Reduces disk access, computation (CPU), and speeds up query results

Indexes Data structure that improves speed of operations on db table Sorted by key values

Query Syntax tips and tricks

Good database design normalization

Data cleaning Old and unused records

Page 13: Database Administration & Optimization

Optimizing query performanceTypes of Database CachingAd hoc - not cached

Easy to debug, but same query executed every timeParameterized queries - cached queries

Replace constant literal values by variables, and compiles query plans. If subsequent query differs in only values of constants, it will match against auto-parameterized query.

Prepare statements – cached handles batch text is sent once at "prepare" time. SQL Server responds

by returning handle that can be used to invoke the batch at execute time. At execute time, a handle and parameter values are sent to server.

Stored procedures - cached parameter sniffing When stored procedure is compiled for first time, values of parameters

supplied with execution call are used to optimize statements within that stored procedure. This process is known as "parameter sniffing." If these values are typical, then most calls to that stored procedure will benefit from stored procedures.

Page 14: Database Administration & Optimization

Optimizing Query PerformanceIndexes Clustered

Defines physical storing of rows (reorders how records are physically stored)

Each table can have one clustered index If clustered index not defined, usually Primary Key becomes

clustered index automatically Non-Clustered

logical order of the index does not match the physical stored order of the rows on disk

Contains references to sorting Slows down modification and insertion process, so keep to a

minimum Good candidates for non-clustered indexes are those columns

frequently used in WHERE, GROUP BY, and HAVINGSQL Server’s Tuning Wizard

recommends indexes after running SQL Server Profiler (query optimization tool that traces queries)

Page 15: Database Administration & Optimization

Optimizing Query Performance Syntax tricksAvoid joining tables on non-indexed columns

Most expensive operation SQL Server can doSpecify columns in select statements instead

of SELECT *Try to avoid DISTINCT when possibleRestrict with WHERE clauses Select TOP number of rowsExperiment with switching ORDER BY

column positions

Page 16: Database Administration & Optimization

Optimizing Query Performance(Syntax tricks - cont.)Union ALL faster than Union

UNION ALL does not look for duplicate rows, and UNION statement does look for duplicate rows, whether or not they exist

SET NOCOUNT ON – stored proceduresStops message indicating number of rows and

reduces network traffic because message with number of rows retrieved is not displayed to client

Page 17: Database Administration & Optimization

Backup and Restore ProceduresIT backups

Stored on tapeShip to offsiteBackup requested when needed

SQL Server runs nightly backupsBackups stored on server and replaced by new

versionsTypes of files backed up:

Master file stores system information, user logons, user permissions, etc.

Msdb file stores job content and scheduling information

Other database files

Page 18: Database Administration & Optimization

ConclusionQuestions?