The document provides an overview of debugging techniques for databases. It discusses the history of programming languages and when interactive debuggers first appeared. It describes common debugger functionality like breakpoints and stepping. It also covers profiling tools and examples of using debuggers and profilers to optimize database code. The presentation concludes with a demo of typical database debugging and profiling tools.
8. Famous Bugs
u 1998: NASA’s Mars Climate Orbiter lost in
space: (units problem)
u Ariane 5 Flight 501 self-destructs after
multiple computer failures (1996)
u Soviet Gas Pipeline in 1982 – stolen
automated control software (CIA hacked)
u Morris Worm – a harmless coding
experiment became a worm (Cornell Univ
- 1988)
u Pentium chip math error (1993)
u Apple Maps (2012) – disastrous launch
u AT&T long distance outage (1990) costs
$60m
u UK insurance company (1993) database
wipes data
9. file://localhost/Users/robinbloor2/Dropbox/~Deskto
p/bottlenecks.jpg
The Impedance Mismatch
The RDBMS stores data
organized in tables
The OO coder manipulates data
organized in object structures,
with associated methods
The data does not simply map to
the database table structures so
a mapping is necessary
Basically: hierarchies, types,
result sets, poor APIs, language
bindings, tools
10. file://localhost/Users/robinbloor2/Dropbox/~Deskto
p/bottlenecks.jpg
The Impedance Mismatch
SQL has:
DDL (for data definition)
DML (for Select, Project and
Join)
But it has little MML (Math) or
TML (Time)
Usually result sets are brought to
the client for further analytical
manipulation, but this creates
problems
Alternatively doing all analytical
manipulation in the database
creates problems
12. Database Performance Factors
Bad database design
Bad program design
Concurrency, workload
mixing
Load balancing
Capacity planning – data
growth
Data layer issues
13. In A Few Words
Database debugging can be onerous
and non-trivial
16. There are many stories about how the terms “bug” and
“debugging” came about – one of them claims that “On
September 9, 1945, in the USA, a Harvard technical
team looked at Panel F of the Harvard's Mark II
computer, and found something unusual between points
in Relay 70”.
17. Apparently it was a moth, which they promptly
removed and taped in the log book. Supposedly the
legendary Grace Hopper added a caption which read
“First actual case of bug being found," and it’s long
been claimed that this was the first time anyone used
the word bug to describe a computer glitch. Naturally,
the term debugging followed.
22. x$objQuery = $this->db->query
( "SELECT rd.*, ((rd.rd_numberofrooms) - (select
sum(rn.reservation_numberofrooms) as
count_reserve_room from reservation as rn WHERE
rn.reservation_rd_id = rd.rd_id AND
(str_to_date('$data_Check_in_date','%d-%m-%y')
BETWEEN
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND
str_to_date(rn.reservation_check_out_date,'%d-%m-
%y') OR str_to_date('$data_Check_out_date','%d-%m-
%y') BETWEEN
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND
str_to_date(rn.reservation_check_out_date,'%d-%m-
%y') OR str_to_date('$data_Check_in_date','%d-%m-
%y') <=
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND str_to_date('$data_Check_out_date','%d-%m-
%y') ) )) as reserve
FROM room_details rd LEFT JOIN reservation rn ON
rd.rd_id = rn.reservation_rd_id WHERE NOT EXISTS
(
SELECT rn.* FROM reservation rn WHERE
rn.reservation_rd_id = rd.rd_id
AND (str_to_date('$data_Check_in_date','%d-%m-%y')
BETWEEN
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND
str_to_date(rn.reservation_check_out_date,'%d-%m-
%y') OR str_to_date('$data_Check_out_date','%d-%m-
%y') BETWEEN
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND
str_to_date(rn.reservation_check_out_date,'%d-%m-
%y') OR str_to_date('$data_Check_in_date','%d-%m-
%y') <=
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND str_to_date('$data_Check_out_date','%d-%m-
%y') >=
str_to_date(rn.reservation_check_out_date,'%d-%m-
%y'))
AND (rd.rd_numberofrooms <= (select
sum(rn.reservation_numberofrooms) as
count_reserve_room from reservation as rn WHERE
rn.reservation_rd_id = rd.rd_id AND
(str_to_date('$data_Check_in_date','%d-%m-%y')
BETWEEN
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND
str_to_date(rn.reservation_check_out_date,'%d-%m-
%y') OR str_to_date('$data_Check_out_date','%d-%m-
%y') BETWEEN
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND
str_to_date(rn.reservation_check_out_date,'%d-%m-
%y') OR str_to_date('$data_Check_in_date','%d-%m-
%y') <=
str_to_date(rn.reservation_check_in_date,'%d-%m-
%y') AND str_to_date('$data_Check_out_date','%d-%m-
%y') ) ) )
)
");
www.quora.com/Whats-the-most-complex-SQL-query-you-ever-wrote