Sie sind auf Seite 1von 13

2.

Performance problems

7/24/13 10:22 PM

Performance problems

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

What can go wrong ?


Problems related to Database Management Systems
Problems related to user applications
Problems related to database design
Problem related to transaction processing

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problem related to DBMS


Incorrect configuration of DBMS, e.g. to small size of
shared memory area, too small size of database
cache, incorrect assignments of relational tables to
database caches
Incorrect configuration of persistent storage, e.g. log
files located on the same disk drive as database
files, frequently used relational tables located on the
same disk drive
Not enough hardware resources to support a
software system, e.g. installation of Oracle 11g on a
laptop
Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problems related to user applications


Inefficient SQL
Example
CUSTOMER(c#, name, address) PK = (c#)
ORDERS(o#, c#, total) PK =(o#), FK = (c#)
Find the total number of orders submitted by a customer
whose number is 007
SELECT COUNT(*)
FROM ORDERS JOIN CUSTOMER
ON ORDERS.c# = CUSTOMER.c#
WHERE CUSTOMER.c# = 007;
SELECT COUNT(*)
FROM ORDERS
WHERE ORDERS.c# = 007;
Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problems related to user applications


Domination of procedural code over SQL
Example
Find the names of customers who submitted orders worth
more than 1000
for customer in CUSTOMER do
for order in ORDERS do
if customer.c# = order.c# and
order.total > 1000 then
display customer.name
SELECT name
FROM ORDERS JOIN CUSTOMER
ON ORDERS.c# = CUSTOMER.c#
WHERE total > 1000;
Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problems related to user applications


Domination of SQL over procedural code
Example
Find the orders with the second highest total value
SELECT *
FROM ORDERS
WHERE ORDERS.total =
( SELECT MAX(total)
FROM ORDERS
WHERE total <>
( SELECT MAX(total)
FROM ORDERS ) );

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problems related to database design


Database logical design not consistent with
database applications
Example
R(driver, truck, capacity)
driver truck, truck capacity not 3NF !
D(driver, truck)
T(truck, capacity) BCNF !
Find all drivers who use trucks with capacity greater than 100
SELECT driver
FROM D JOIN T
ON D.truck = T.truck
WHERE capacity > 100;
Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problems related to database design


Database logical design not consistent with
database applications
Example
R(driver, truck, capacity)
driver truck, truck capacity not 3NF !
D(driver, truck)
C(driver, capacity) BCNF !
Find all drivers who use trucks with capacity greater than 100
SELECT driver
FROM C
WHERE capacity > 100;

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problems related to database design


Database physical design not consistent with
database applications
Example
ORDERS(o#, c#, total) PK =(o#), FK = (c#)
Find all orders whose total value equal to 1000
SELECT *
FROM ORDERS
WHERE total = 1000;
Missing index on ORDERS(total) forces a full scan of a
relational table ORDERS

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

2. Performance problems

7/24/13 10:22 PM

Problems related to database design


Overnormalization
Example
STREETS(street, zcode)
CITIES(city, zcode)
PK =(street, zcode)
PK = (zcode)
BCNF
BCNF
Find all streets in Sydney
SELECT street
FROM STREETS JOIN CITIES
ON
STREETS.zcode = CITIES.zcode
WHERE city = 'Sydney';

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

10

2. Performance problems

7/24/13 10:22 PM

Problems related to database design


Overnormalization
Example
LOCATION(city,street,zcode)
PK =(city,street), CK = (zcode,street)
city,street zcode zcode city
3NF not BCNF
Find all streets in Sydney
SELECT street
FROM LOCATION
WHERE city = 'Sydney';

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

11

2. Performance problems

7/24/13 10:22 PM

Problems related to database design


Fragmentation of persistent storage
Example
A relational table stored in the data blocks

After deletions persistent storage is not automatically


defragmented

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

12

2. Performance problems

7/24/13 10:22 PM

Problems related to transaction processing


Concurrency control protocols
Example
Transaction Ti
Transaction Tk
while not eot(ORDERS)
read(ORDERS.total;
read(ORDERS.total)
where o# = 777)
write(ORDERS.total+10) write(ORDERS.total-20)
end
COMMIT;
COMMIT;
Transaction Ti blocks transaction Tk because COMMIT of Ti is
performed after all updates.

Janusz R. Getta

CSCI317/MCS9317 Database Performance Tuning, SCSSE, Spring 2013

13

Das könnte Ihnen auch gefallen