# Query Processing and Optimization

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Query Processing and Optimization Query optimization: finding a good way to evaluate a query Queries are declarative, and can be translated into procedural languages in more than one way Hence one has to choose the best (or at least good) procedural query This happens in the context of query processing A query processor turns queries and updates into sequences of of operations on the database Database Systems 1 L. Libkin

2 Query processing and optimization stages Which relational algebra expression, equivalent to a given declarative query, will lead to the most efficient algorithm? For each algebraic operator, what algorithm do we use to compute that operator? How do operations pass data (main memory buffer, disk buffer?) We first concentrate the first step: finding efficient relational algebra expressions For the second step, we need to know how data is stored, and how it is accessed Database Systems 2 L. Libkin

3 Overview of query processing Start with a declarative query: SELECT R.A, S.B, T.E FROM R,S,T WHERE R.C=S.C AND S.D=T.D AND R.A>5 AND S.B<3 AND T.D=T.E Translate into an algebra expression: π R.A,S.B,T.E (σ R.A>5 S.B<3 T.D=T.E (R S T)) Optimization step: rewrite to an equivalent but more efficient expression: π R.A,S.B,T.E (σ A>5 (R) σ B<3 (S) σ D=E (T))) Why is it more efficient? Because selections are evaluated early, and joined relations are not as large as R, S,T. Database Systems 3 L. Libkin

4 Overview of query processing cont d Evaluating the optimized expression. Choices to make: order of joins. Two possible query plans: A,B A>5 B<3 D=E R S T first joins S, T, and then joins the result with R. Database Systems 4 L. Libkin

5 Another query plan: Overview of query processing cont d A,B A>5 B<3 D=E R S T It first joins S, T, and then joins the result with R. Both query plans produce the same result. How to choose one? Database Systems 5 L. Libkin

6 Optimization by algebraic manipulations Given a relational algebra expression e, find another expression e equivalent to e that is easier (faster) to evaluate. Basic question: Given two relational algebra expressions e 1,e 2, are they equivalent? This is the same as asking if an expression e always produces the empty answer: e 1 = e 2 e 1 e 2 = and e 2 e 1 = Problem: testing e = is undecidable for relational algebra expressions. Good news: We can still list some useful equalities, and It is decidable for very important classes of queries (SPJ queries) Database Systems 6 L. Libkin

7 Optimization by algebraic manipulations Join and Cartesian product are commutative and associative, hence they can be applied in any order: R S = S R R (S T) = (R S) T R S = S R R (S T) = (R S) T Cascade of projections. Assume that attributes A 1,...,A n are among B 1,...,B m. Then Cascade of selections: π A1,...,A n (π B1,...,B m (E)) = π A1,...,A n (E) σ c1 (σ c2 (E)) = σ c1 c 2 (E) Database Systems 7 L. Libkin

8 Optimization by algebraic manipulations Commuting selections and projections. Assume that condition c involves attributes A 1,...,A n, B 1,...,B m. Then π A1,...,A n (σ c (E)) = π A1,...,A n (σ c (π A1,...,A n, B 1,...,B m (E))) A useful special case: if c only involves attributes A 1,...,A n, then π A1,...,A n (σ c (E)) = σ c (π A1,...,A n (E)) Commuting selection with join. If c only involves attributes from E 1, then σ c (E 1 E 2 ) = σ c (E 1 ) E 2 Database Systems 8 L. Libkin

9 Optimization by algebraic manipulations cont d Let c 1 only mention attributes of E 1 and c 2 only mention attributes of E 2. Then σ c1 c 2 (E 1 E 2 ) = σ c1 (E 1 ) σ c2 (E 2 ) Because: σ c1 c 2 (E 1 E 2 ) = σ c1 (σ c2 (E 1 E 2 )) = σ c1 (E 1 σ c2 (E 2 )) = σ c1 (E 1 ) σ c2 (E 2 ) Another useful rule: If c only mentions attributes present in both E 1 and E 2, then σ c (E 1 E 2 ) = σ c (E 1 ) σ c (E 2 ) Database Systems 9 L. Libkin

10 Optimization by algebraic manipulations cont d Rules combining σ,π with and Commuting selection and union: σ c (E 1 E 2 ) = σ c (E 1 ) σ c (E 2 ) Commuting selection and difference: Commuting projection and union: σ c (E 1 E 2 ) = σ c (E 1 ) σ c (E 2 ) π A1,...,A n (E 1 E 2 ) = π A1,...,A n (E 1 ) π A1,...,A n (E 2 ) Question: what about projection and difference? Is π A (E 1 E 2 ) equal to π A (E 1 ) π A (E 2 )? Database Systems 10 L. Libkin

11 Optimization by algebraic manipulations: example Recall π R.A,S.B,T.E (σ R.A>5 S.B<3 T.D=T.E (R S T)) Optimization: pushing selections π R.A,S.B,T.E (σ R.A>5 S.B<3 T.D=T.E (R S T)) = π R.A,S.B,T.E (σ R.A>5 (σ S.B<3 (σ T.D=T.E (R S T)))) = π R.A,S.B,T.E (σ R.A>5 (σ S.B<3 (R S (σ T.D=T.E (T))))) = π R.A,S.B,T.E (σ R.A>5 (R σ S.B<3 (S) (σ T.D=T.E (T)))) = π R.A,S.B,T.E (σ A>5 (R) σ B<3 (S) σ D=E (T))) Database Systems 11 L. Libkin

12 Implementation of individual operations Depends on access method and file organization Suppose EmplId is a key; how long does it take to answer: Time is linear in the worst case σ EmplId= (Employee)? But one can perform the selection much faster if there is an index on attribute EmplId Index: auxiliary structure that provides fast access to tuples in a table based on a given key value Most common example: B-trees With B-trees, the above selection takes O(log n) Database Systems 12 L. Libkin

13 Note on indices and SQL SQL allows one to create an index on a given attribute or a sequence of attributes Once an index is created, the table can be accessed fast if the values of index attributes are known SQL always creates an index for attributes declared as a primary key of a table Syntax: CREATE INDEX <Index_Name> ON <Table_Name>(<attr1>,...,<attrN>) Example: CREATE INDEX EmplIndex ON Employee(EmplId) Database Systems 13 L. Libkin

14 Processing individual operators: join Join is the costliest operator of relational algebra Query: R S = σ R.A=S.A (R S) SELECT R.A, R.B, S.C FROM R, S WHERE R.A=S.A Naive implementation: for every tuple t1 in R do for every tuple t2 in S do if t1.a=t2.a then output (t1.a,t1.b,t2.c) end end Time complexity: O(n 2 ) Database Systems 14 L. Libkin

15 Join processing Assumption: R.A is the primary key of R. New O(n log n) algorithm: Sort R and S on attribute A; scans := first tuple in S; for each tuple t1 in R do scan S starting from scans until a tuple t2 with t2.a t1.a is found; if t2.a=t1.a then while t2.a=t1.a do if t1.a=t2.a then output (t1.a,t1.b,t2.c); move to the next tuple t2 of S end set scans := current tuple t2 end Database Systems 15 L. Libkin

16 Join processing cont d Previous algorithm can be extended to the case when the common attributes of R and S do not form a key in either relation One uses two pointers then to scan the relations Name: Sort-Merge join Both algorithms would be implemented differently in practice No need to do a new disk read to get each tuple; instead, read one block at a time Complexity of sort-merge join: If the relations are sorted, it requires B R + B S disk reads, where B R, B S are the numbers of disk blocks in R, S. Database Systems 16 L. Libkin

17 Reminder: hashing. Join processing: hash join Bucket a unit of storage that can store one or more tuples. Typically several disk blocks K a set of search-key values; B a set of buckets Hash function h : K B Good properties: uniform, random distribution Example of hashing: first two digits of the student # (assumes 100 buckets) Example of bad hashing: (account balance mod ) div Overflows. Reason: bad distribution, insufficient buckets. Handling of overflows: a linked list of overflow buckets Database Systems 17 L. Libkin

18 Join processing: hash join of R and S X - the set of common attributes Step 1: Select M, the number of buckets Step 2: Select a hash function h on attributes from X: h : {tuples over X} {1,...,M} Step 3: Partition R and S: for each t in R do i := h(t.x) Hi R := Hi R {t} end for each t in S do i := h(t.x) Hi S := Hi S {t} end If there are no overflows, this requires O(B R + B S ) I/O operations (read the relations, and write them back) With overflows, one uses recursive partitioning, and then complexity becomes O(n log n), where n = B R + B S. Database Systems 18 L. Libkin

19 Join processing: hash join of R and S Assume that the relations are partitioned Algorithm: for i = 1 to M do read H R i read H S i add H R i H S i to the output end Why does it work? If two tuples t 1 R, t 2 S match, t 1.X = t 2.X and h(t 1 ) = h(t 2 ); hence they are in the same partition class Improvements: how does one compute Hi R Hi S? One possibility: use another hash function. If it doesn t create overflows, the time for the algorithm is O(B R + B S ) Database Systems 19 L. Libkin

20 Using hash functions for Boolean operations Observe: R S = (H R 1 H S 1 )... (H R M H S M) Because: if t R S and t H R i, then t H S i Advantage: each tuple t R must only be compared with H S h(t), and not with the whole relation S Using hash functions for difference: for each t in R do i := h(t) if t H S i, include t in the output end Database Systems 20 L. Libkin

21 Other operations Set union R S: if no index is needed on the result, just append S to R If index is needed, then do as above, and then build a new index Duplicate elimination: On a sorted relation, it takes linear time. Thus, sort relation R first, based on any attribute(s), and then do one pass and eliminate duplicate Complexity: O(n log n). Aggregation with GROUP BY: similarly, sort on the group by attributes, before computing aggregate functions. Database Systems 21 L. Libkin

22 Query processing cont d Find names of theaters that play movies featuring Nicholson SELECT S.theater FROM Movies M, Schedule S WHERE M.title=S.title AND M.actor= Nicholson Translate into algebra: Next step: choose a query plan π theater (σ actor= Nicholson (M S)) To do so, use algebraic rewritings to create several equivalent expressions, and then choose algorithms for performing individual operators. Database Systems 22 L. Libkin

23 Query processing cont d Step 1 S.theater S.theater S.theater M.act= Nicholson M.title=S.title X M S M.act= Nicholson S M.act= Nicholson S M PLAN 1 PLAN 2 PLAN 3 M Database Systems 23 L. Libkin

24 Query processing cont d Step 2 S.theater S.theater S.theater M.act= Nicholson M.title=S.title (hash join) X (sort merge join, M.title is key) M S M.act= Nicholson S M.act= Nicholson S M PLAN 1 PLAN 2 PLAN 3 M Database Systems 24 L. Libkin

25 Query processing cont d Choosing the best plan: cost-based optimization Query optimizer estimates the cost of evaluating each plan Particularly important: selectivity estimation (how many tuples in σ c (E)?) and join size estimation Techniques used: statistics. Sometimes a sampling is done before a query is processed. Problem with cost-based optimization: the set of all query plans is extremely large; the optimizer cannot try them all Another problem: how long can the optimizer run? Hopefully not as long as the savings it provides. Database Systems 25 L. Libkin

26 Join order We know that join is commutative and associative. How does one evaluate R 1 R 2 R 3 R 4 R 5? Possibilities: ( ( (R 1 R 2 ) R 3 ) R 4 ) R 5 (R 1 R 2 ) (R 3 (R 4 R 5 )) (R 1 (R 3 R 5 )) (R 4 R 2 ) Database Systems 26 L. Libkin

27 Join order R5 R4 R1 R2 R3 R3 R1 R2 R4 R5 DB2 optimizer only considers deep join orders like the one on the left. In general, choosing an optimal join order is computationally hard (usually NP-complete for reasonable cost measures) Database Systems 27 L. Libkin

28 SQL and query optimization Query optimizer helps turn your query into a more efficient one, but you can help the query optimizer do its job better. The search space of all possible query plans is extremely large, and optimizers only run for a short time, and thus may fail to find a good plan. There are several rules that usually ensure a better query plan; however, a lot depends on a particular system, version, and its optimizers, and these rules may not be universally applicable. Still, if your query isn t running fast enough, it s worth giving them a try. Database Systems 28 L. Libkin

29 SELECT * FROM Students WHERE grade= A AND sex= female Order does matter! is better than SELECT * FROM Students WHERE sex= female AND grade= A Because usually there are fewer A students than female students. Using orders instead of <> SELECT * FROM Movies WHERE Length > 120 OR Length < 120 is better than SELECT * FROM Movies WHERE Length <> 120 Because the ordered version forces SQL to use an index on Length, if there is one Without such an index, the version with OR runs longer Database Systems 29 L. Libkin

30 Provide more JOIN information SELECT * FROM T1, T2, T3 WHERE T1.common = T3.common AND T1.common=T2.common SELECT * FROM T1, T2, T3 WHERE T1.common = T3.common AND T3.common=T2.common These may not be as good as SELECT * FROM T1, T2, T3 WHERE T1.common = T2.common AND T2.common = T3.common AND T3.common = T1.common Database Systems 30 L. Libkin

31 SELECT * FROM Personnel WHERE location= Edinburgh UNION SELECT * FROM Personnel WHERE location= Glasgow is not as good as SELECT DISTINCT* FROM Personnel WHERE location= Edinburgh OR location= Glasgow Avoid unions if OR is sufficient The optimizer normally works within a single SELECT-FROM-WHERE. Database Systems 31 L. Libkin

32 Joins are better than nested queries SELECT S.Theater FROM Schedule S WHERE S.Title IN (SELECT M.Title FROM Movies M WHERE M.director= Spielberg ) is likely to run slower than SELECT S.Theater FROM Schedule S, Movies M WHERE S.Title = M.Title AND M.director= Spielberg Database Systems 32 L. Libkin

33 Transactions and Concurrency Control Transaction: a unit of program execution that accesses and possibly updates some data items. A transaction is a collection of operations that logically form a single unit. Executing a transaction: either all operations are executed, or none are. Each transactions may consist of several steps, some involving I/O activity, and some CPU activity. Moreover, typically several transactions are running on a system; some are long, some are short. This creates an opportunity for concurrent execution. Problem: how to ensure consistency? Database Systems 33 L. Libkin

34 Transaction model Operation read(x) transfers the data item X from the database to a local buffer belonging to the transaction Operation write(x) transfers the data item X from the local buffer back to the database Example: transfer \$100 from account A to account B read(a); A := A - 100; write(a); read(b); B := B + 100; write(b) It executes as a single unit: at no point between read(a) and write(b) can a user query the database, as it might be in an inconsistent state. Database Systems 34 L. Libkin

35 ACID properties Atomicity: either all operations of a transaction are reflected properly in the database, or none are. Consistency: execution of a transaction in isolation preserves the consistency of the database. Isolation: even though many transactions may run concurrently, the DBMS ensures that for any two transactions T,T, it appears to T that either T finished before T started, or T started execution after T finished. Durability: after a transaction completes successfully, the changes it has made persist. Database Systems 35 L. Libkin

36 States of a transaction Active: it stays in this state while it is executing Partially committed: after the final statement has been executed. Failed: after the discovery that normal execution cannot proceed. Aborted: after it has been rolled back, and the database state restored to the one prior to the start of the execution. Committed: after successful completion. PARTIALLY COMMITTED COMMITTED ACTIVE FAILED ABORTED Database Systems 36 L. Libkin

37 Two transactions T takes \$100 from account A to account B. T takes 10% of account A to account B. Property of T and T : they don t change A+B. Money isn t created, and doesn t disappear. T: read(a); A := A - 100; write(a); read(b); B = B+100; write(b) T : read(a); tmp := A*0.1; A := A - tmp; write(a); read(b); B = B+tmp; write(b) Database Systems 37 L. Libkin

38 Two serial executions: T; T and T ; T T T read(a); A := A - 100; write(a); read(b); B = B+100; write(b); read(a); tmp := A*0.1; A := A - tmp; write(a); read(b); B = B+tmp; write(b); T read(a); tmp := A*0.1; A := A - tmp; write(a); read(b); B = B+tmp; write(b); T read(a); A := A - 100; write(a); read(b); B = B+100; write(b); Database Systems 38 L. Libkin

39 Transaction invariant A+B doesn t change after T and T execute. Assume that both A and B have \$1,000. Evaluating T;T : after T: A=900, B=1100. after T : A=810, B=1190. A+B=2000. Evaluating T ; T: after T : A=900, B=1100 after T: A=800, B=1200. A+B=2000. Database Systems 39 L. Libkin

40 Concurrent execution I T T read(a); A := A - 100; write(a); read(a); tmp := A*0.1; A := A - tmp; write(a); read(b); B = B+100; write(b); read(b); B = B+tmp; write(b); Result: A=810 B=1190 A+B=2000 Database Systems 40 L. Libkin

41 Concurrent execution II T T read(a); A := A - 100; read(a); tmp := A*0.1; A := A - tmp; write(a); write(a); read(b); B = B+100; write(b); read(b); B = B+tmp; write(b); Result: A=900 B=1200 A+B=2100 We created \$100! Database Systems 41 L. Libkin

42 Serializability Why is schedule I good and schedule II bad? Because schedule I is equivalent to a serial execution of T and T, and schedule II is not. We formalize this via conflict serializability. Transaction scheduling in DBMSs always ensures serializability. Simplified representation of transactions For scheduling, the only important operations are read and write. What operations are performed on each data item does not affect the schedule. We thus represent transactions by a sequence of read-write operations, assuming that between each read(a) and write(a) some computation is done on A. Database Systems 42 L. Libkin

43 Simplified representation of transactions cont d Examples of two concurrent executions in the new model: Schedule I Schedule II T T read(a); write(a); read(a); write(a); read(b); write(b); read(b); write(b); T T read(a); read(a); write(a); write(a); read(b); write(b); read(b); write(b); Database Systems 43 L. Libkin

44 Analyzing conflicts Let Op 1 and Op 2 be two consecutive operations in a schedule. Conflict the order matters: may give us different results. Op 1 ; Op 2 and Op 2 ; Op 1 If there is no conflict, Op 1 and Op 2 can be swapped. If Op 1 and Op 2 refer to different data items, they do not cause a conflict, and can be swapped. If they are both operations on the same data item X, then: if both are read(x), the order does not matter; if Op 1 =read(x), Op 2 =write(x), the order matters. if Op 1 =write(x), Op 2 =read(x), the order matters. if Op 1 =write(x), Op 2 =write(x), the order matters. Database Systems 44 L. Libkin

45 Conflict serializability Swapping a pair of operations in a schedule is allowed when: they refer to different data items, or, they refer to the same data item and are both read operations. A schedule is called conflict serializable if it can be transformed into a serial schedule by a sequence of such swap operations. Database Systems 45 L. Libkin

47 Schedule II is not conflict serializable T T read(a); read(a); write(a); write(a); read(b); write(b); read(b); write(b); In a serial schedule, either: write(a) by T precedes read(a) by T, or write(a) by T precedes read(a) by T But: write(a) by T cannot be swapped with write(a) by T, and write(a) by T cannot be swapped with read(a) by T Hence the schedule is not serializable. Database Systems 47 L. Libkin

48 Testing conflict serializability Construct the precedence graph of a schedule S Nodes: transactions in the system Edges: there is an edge T T if T executes an operation Op 1 before T executes an operation Op 2 such that Op 1 and Op 2 cannot be swapped. That is, one of these conditions holds: T executes write(x) before T executes read(x) T executes read(x) before T executes write(x) T executes write(x) before T executes write(x) Database Systems 48 L. Libkin

49 Testing conflict serializability Given a schedule S, construct its precedence graph If there is an edge T T, then in any serial schedule S equivalent to S, the transaction T must appear before T. A schedule S is conflict serializable if and only if its precedence graph contains no cycles. Testing serializability: Construct the conflict graph Check if it has cycles If it doesn t have cycles, do topological sort The result of the topological sort gives an equivalent serial schedule. Reminder: a topological sort of an acyclic graph G produces an order on its nodes consistent with G if there is an edge from x to y, then x y. Database Systems 49 L. Libkin

50 Testing conflict serializability: examples T T PRECEDENCE GRAPH FOR SCHEDULE I T T PRECEDENCE GRAPH FOR SCHEDULE 2 Thus, schedule I is conflict serializable, and schedule II is not. Database Systems 50 L. Libkin

51 Concurrency control: lock-based protocols Main goal of concurrency control: to ensure the isolation property for concurrently running transactions Typically achieved via locks Each data item is locked by at most one transaction; while it is locked, no other transaction has access to it. Two new primitives: lock(a) and unlock(a) A typical transaction:... lock(a); read(a);... write(a); unlock(a);... Database Systems 51 L. Libkin

52 Locking and serializability A new abstract view of transaction: only the order of lock and unlock operations matters If data item A is locked by transaction T, and transaction T issues a lock(a) command, it must wait until T executes unlock(a). New representation of schedules: Schedule S 1 Schedule S 2 T 2 : lock(a) T 1 : lock(a) T 2 : unlock(a) T 2 : lock(b) T 3 : lock(a) T 2 : unlock(b) T 3 : unlock(a) T 1 : lock(b) T 1 : lock(b) T 1 : unlock(a) T 1 : unlock(b) T 2 : lock(a) T 2 : lock(b) T 2 : unlock(a) T 2 : unlock(b) T 1 : unlock(b) Database Systems 52 L. Libkin

53 Locking and serializability Precedence graph: for each operation T i : unlock(a), locate the following T j : lock(a) statement, and put an edge from T i to T j Conflict-serializability with locking: a schedule is conflict-serializable if the precedence graph does not have cycles. Precedence graphs: T1 T2 T3 FOR S1 T1 T2 FOR S2 Hence S 1 is conflict-serializable, S 2 is not. Database Systems 53 L. Libkin

54 Locking and serializability cont d A conflict-serializable schedule of lock-unlock operations ensures a conflict-serializable schedule of read-write operations: T 2 lock(a) T 2 unlock(a) T 1 lock(b) T 1 unlock(b) T 2 lock(b) T 2 unlock(b) T 1 T 2 read(a) write(a) read(b) write(b) read(b) write(b) T 1 T 2 read(b) write(b) read(a) write(a) read(b) write(b) Database Systems 54 L. Libkin

55 Two-phase locking A protocol which guarantees conflict-serializable schedule Used in most commercial DBMSs Each transaction has two phases: Growing phase: a transaction may request new locks, but may not release any locks Shrinking phase: a transaction may release locks, but may not request any locks That is, after transaction released a lock, it may not request any new locks Main property of two-phase locking: A schedule S in which every transaction satisfies the two-phase locking protocol is conflict-serializable Database Systems 55 L. Libkin

56 Two-phase locking and serializability: proof Assume that every transaction conforms to the two-phase locking protocol (or: is a 2PL transaction) Assume S is not serializable, and the precedence graph contains a cycle: Trace the cycle: - T 1 locks and unlocks something - T 2 locks and unlocks something T k locks and unlocks something - T 1 locks and unlocks something T 1 T 2 T 3... T k T 1 Then T 1 locks some data item after it released a lock, and hence it is not 2PL. Database Systems 56 L. Libkin

57 Two-phase locking and serializability cont d The result is best possible For any non-2pl transaction T, there is a 2PL transaction T and a schedule S for T,T that is not serializable. Idea: T lock(a) unlock(a) lock(b) unlock(b) Schedule: T lock(a), unlock(a) all operations T lock(b), unlock(b) T This schedule is not serializable. T lock(a) lock(b) unlock(a) unlock(b) Database Systems 57 L. Libkin

58 2PL in practice Majority of commercial DBMSs implement some form of 2PL Rigorous 2PL: all locks must be held until the transaction commits Two types of locks: Exclusive: the transaction can both read and write the data item Shared: the transaction can only read the data item At most one transaction can possess an exclusive lock for a data item at any given time, but several transactions can possess a shared lock Strict 2PL: all exclusive locks taken by the transaction must be held until it commits Strict and rigorous 2PL are the most common concurrency control mechanisms Database Systems 58 L. Libkin

59 Deadlocks time T 1 T 2 1 lock(a) 2 lock(b) 3 lock(b) now T 1 waits for T 2 to unlock B 4 lock(a) now T 2 waits for T 1 to unlock A Deadlock: T 1 waits for T 2, T 2 waits for T 1 In general, there is a set of transactions T 1,...,T k such that: - T 1 waits for T 2 - T 2 waits for T T k waits for T 1 Database Systems 59 L. Libkin

60 Dealing with deadlocks Two main mechanisms: prevention and detection Prevention: find a concurrency control mechanism which ensures that there is no waits-for cycle Simple deadlock prevention: each transaction locks all data items before it starts execution. Such a locking constitutes one step. Disadvantage: data utilization is very low Another approach: use preemption. If T 1 has a lock on A, and T 2 requests it, then the system has three choices: - let T 2 wait, or - roll back T 1 and grant the lock to T 2, or - roll back T 2 Database Systems 60 L. Libkin

61 Deadlock prevention cont d The decision is based on timestamps, that say how old transactions are. Timestamp: the time when transaction started its execution. The larger the timestamp, the younger the transaction. Example: the wound-wait scheme. If T 1 requests a lock held by T 2, then T 1 waits if T 1 is younger than T 2. Otherwise T 2 is rolled back. The wait-die scheme. If T 1 requests a lock held by T 2, then T 1 waits if T 1 is older than T 2. Otherwise T 1 is rolled back. Issue: starvation may occur. Some transactions may never commit, as they keep being rolled back. Database Systems 61 L. Libkin

62 Deadlock detection and recovery The wait-for graph. Nodes are transactions. There is an edge from T to T if T waits for T to release a lock. There is a deadlock if there is a cycle in the wait-for graph. Deadlock recovery: identify a minimal set of transactions such that rolling them back will make the wait-for graph cycle-free. T1 T2 T4 T1 T4 T3 T3 DEADLOCK AFTER DELETING T2 Database Systems 62 L. Libkin

### Transaction Concept. Chapter 15: Transactions. ACID Properties. Example of Fund Transfer. Transaction State. Example of Fund Transfer (Cont.

Chapter 15: Transactions Transaction Concept! Transaction Concept! Transaction State! Implementation of Atomicity and Durability! Concurrent Executions! Serializability! Recoverability! Implementation

### Chapter 14: Transactions

Chapter 14: Transactions Transaction Concept Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. E.g. transaction to transfer \$50 from

### Textbook and References

Transactions Qin Xu 4-323A Life Science Building, Shanghai Jiao Tong University Email: xuqin523@sjtu.edu.cn Tel: 34204573(O) Webpage: http://cbb.sjtu.edu.cn/~qinxu/ Webpage for DBMS Textbook and References

### Chapter 15: Transactions

Chapter 15: Transactions Database System Concepts, 5th Ed. See www.db book.com for conditions on re use Chapter 15: Transactions Transaction Concept Transaction State Concurrent Executions Serializability

### Transactions. Transactions. Transaction Concept. Example of Fund Transfer

Transactions! Transaction Concept! Transaction State! Concurrent Executions! Serializability! Recoverability! Implementation of Isolation! Transaction Definition in SQL! Testing for Serializability. Transactions

### Course Content. Transactions and Concurrency Control. Objectives of Lecture 4 Transactions and Concurrency Control

Database Management Systems Fall 2001 CMPUT 391: Transactions & Concurrency Control Dr. Osmar R. Zaïane University of Alberta Chapters 18 and 19 of Textbook Course Content Introduction Database Design

### Comp 5311 Database Management Systems. 16. Review 2 (Physical Level)

Comp 5311 Database Management Systems 16. Review 2 (Physical Level) 1 Main Topics Indexing Join Algorithms Query Processing and Optimization Transactions and Concurrency Control 2 Indexing Used for faster

### CS143 Notes: TRANSACTION

CS143 Notes: TRANSACTION Book Chapters (4th) Chapters 15, 16.1, 16.7-8, 17.1-4, 17.6 (5th) Chapters 15, 16.1, 16.7-8, 17.1-5 (6th) Chapters 14, 15.1, 15.8-9, 16.1-5 MOTIVATION FOR TRANSACTION 1. Crash

### CS34800 Information Systems

CS34800 Information Systems Update and Transactions Prof. Chris Clifton 19 October 2016 Deletion Delete all instructors delete from instructor Delete all instructors from the Finance department delete

### Chapter 9. Transaction Management and Concurrency Control. Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel

Chapter 9 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel 1 In this chapter, you will learn: What a database transaction

### Review: The ACID properties

Recovery Review: The ACID properties A tomicity: All actions in the Xaction happen, or none happen. C onsistency: If each Xaction is consistent, and the DB starts consistent, it ends up consistent. I solation:

### CS127 Homework #6. Due: November 28th, :59 P.M.

CS127 Homework #6 Warmup #1 (Textbook Problem 13.15) Suppose that a B+-tree index on (dept name, building) is available on relation department. What would be the best way to handle the following selection?

### Lecture 7: Concurrency control. Rasmus Pagh

Lecture 7: Concurrency control Rasmus Pagh 1 Today s lecture Concurrency control basics Conflicts and serializability Locking Isolation levels in SQL Optimistic concurrency control Transaction tuning Transaction

### Concurrency Control. Module 6, Lectures 1 and 2

Concurrency Control Module 6, Lectures 1 and 2 The controlling intelligence understands its own nature, and what it does, and whereon it works. -- Marcus Aurelius Antoninus, 121-180 A. D. Database Management

### Transactions and Recovery. Database Systems Lecture 15 Natasha Alechina

Database Systems Lecture 15 Natasha Alechina In This Lecture Transactions Recovery System and Media Failures Concurrency Concurrency problems For more information Connolly and Begg chapter 20 Ullmanand

### Transactions. Rasmus Pagh. Literature: KBL Introduction to Database Design 2. Cursory: KBL (complete version: Digital appendix A.

Transactions Rasmus Pagh Literature: KBL 13.1 Cursory: KBL 13.2-13.3 (complete version: Digital appendix A.1) Introduction to Database Design 2 Mid-term evaluation Thanks to those who participated! Points

### G.H. Raisoni College of Engineering & Management, Amravati. Question Bank (DBMS) Third Year CSE

G.H. Raisoni College of Engineering & Management, Amravati. Question Bank (DBMS) Third Year CSE UNIT 1 Q.1. Explain the three levels of data abstraction. Q.2. What are the advantages and disadvantages

### Transaction Management Overview

Transaction Management Overview Chapter 16 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Transactions Concurrent execution of user programs is essential for good DBMS performance. Because

### Transaction Models of DDBMS

Transaction Models of DDBMS Topics covered: Transactions Characterization of transactions Formalization of transactions Serializability theory Concurrency control models Locks Transactions The concept

### Chapter 15: Recovery System

Chapter 15: Recovery System Failure Classification Storage Structure Recovery and Atomicity Log-Based Recovery Shadow Paging Recovery With Concurrent Transactions Buffer Management Failure with Loss of

### Concurrency Control. Chapter 17. Comp 521 Files and Databases Fall 2010 1

Concurrency Control Chapter 17 Comp 521 Files and Databases Fall 2010 1 Conflict Serializable Schedules Recall conflicts (WR, RW, WW) were the cause of sequential inconsistency Two schedules are conflict

### Plan for the Query Optimization topic

VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP302 Database Systems Plan for the Query Optimization topic COMP302 Database Systems Query Optimisation_04 1 What is Query

### Transactions. SET08104 Database Systems. Copyright @ Napier University

Transactions SET08104 Database Systems Copyright @ Napier University Concurrency using Transactions The goal in a concurrent DBMS is to allow multiple users to access the database simultaneously without

### B.Sc (Computer Science) Database Management Systems UNIT - IV

1 B.Sc (Computer Science) Database Management Systems UNIT - IV Transaction:- A transaction is any action that reads from or writes to a database. Suppose a customer is purchasing a product using credit

### 8. Query Processing. Query Processing & Optimization

ECS-165A WQ 11 136 8. Query Processing Goals: Understand the basic concepts underlying the steps in query processing and optimization and estimating query processing cost; apply query optimization techniques;

### Database Tuning and Physical Design: Execution of Transactions

Database Tuning and Physical Design: Execution of Transactions David Toman School of Computer Science University of Waterloo Introduction to Databases CS348 David Toman (University of Waterloo) Transaction

### Data Integration and Exchange. L. Libkin 1 Data Integration and Exchange

Data Integration and Exchange L. Libkin 1 Data Integration and Exchange LECTURE 1: Review of Relational Databases Relational model Schemas Relational algebra Relational calculus SQL Constraints (keys,

### Roadmap. 15-721 DB Sys. Design & Impl. Detailed Roadmap. Paper. Transactions - dfn. Reminders: Locking and Consistency

15-721 DB Sys. Design & Impl. Locking and Consistency Christos Faloutsos www.cs.cmu.edu/~christos Roadmap 1) Roots: System R and Ingres 2) Implementation: buffering, indexing, q-opt 3) Transactions: locking,

### Databases 2011 Recovery

Databases 2011 Recovery Christian S. Jensen Computer Science, Aarhus University Transaction basics Logging Undo/Redo recovery No-Undo/Redo Undo/No-Redo No-Undo/No-Redo Checkpointing Outline Recovery 2

SKYUPS MEDIA DBMS IMPTANT QUESTIONS WITH MODEL PAPER 1 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Data Base Management System Model Paper 1 (R13) II CSE II Semester Duration: 3hrs Max Marks: 75 1.

### 2 nd Semester 2008/2009

Chapter 17: System Departamento de Engenharia Informática Instituto Superior Técnico 2 nd Semester 2008/2009 Slides baseados nos slides oficiais do livro Database System c Silberschatz, Korth and Sudarshan.

### Concurrency Control: Locking, Optimistic, Degrees of Consistency

CS262A: Advanced Topics in Computer Systems Joe Hellerstein, Spring 2008 UC Berkeley Concurrency Control: Locking, Optimistic, Degrees of Consistency Transaction Refresher Statement of problem: Database:

### ! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions

Chapter 13: Query Processing Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions Basic Steps in Query

### Distributed Databases

C H A P T E R19 Distributed Databases Practice Exercises 19.1 How might a distributed database designed for a local-area network differ from one designed for a wide-area network? Data transfer on a local-area

### Transactional properties of DBS

Transactional properties of DBS Transaction Concepts Concurrency control Recovery Transactions: Definition Transaction (TA) Unit of work consisting of a sequence of operations Transaction principles (ACID):

### CS2255 DATABASE MANAGEMENT SYSTEM QUESTION BANK

SHRI ANGALAMMAN COLLEGE OF ENGINEERING & TECHNOLOGY (An ISO 9001:2008 Certified Institution) SIRUGANOOR,TRICHY-621105. DEPARTMENT OF INFORMATION TECHNOLOGY CS2255 DATABASE MANAGEMENT SYSTEM QUESTION BANK

### Homework 8. Revision : 2015/04/14 08:13

Carnegie Mellon University Department of Computer Science 15-415/615- Database Applications C. Faloutsos & A. Pavlo, Spring 2015 Prepared by Hong Bin Shim DUE DATE: Thu, 4/23/2015, 1:30pm Homework 8 IMPORTANT

### ICS 434 Advanced Database Systems

ICS 434 Advanced Database Systems Dr. Abdallah Al-Sukairi sukairi@kfupm.edu.sa Second Semester 2003-2004 (032) King Fahd University of Petroleum & Minerals Information & Computer Science Department Outline

### Transaction Management

OVERVIEW OF TRANSACTION MANAGEMENT Tópicos Avançados da Base de Dados Arley Pinto up110370423 (andrapt@gmail.com) Gabriel de Jesus up110370572 (thejesusgaby@gmail.com) TRANSACTION OVERVIEW A transaction

### Transactions: Definition. Transactional properties of DBS. Transactions: Management in DBS. Transactions: Read/Write Model

Transactions: Definition Transactional properties of DBS Transaction Concepts Concurrency control Recovery Important concept Transaction (TA) Unit of work consisting of a sequence of operations Transaction

### Query Processing, optimization, and indexing techniques

Query Processing, optimization, and indexing techniques What s s this tutorial about? From here: SELECT C.name AS Course, count(s.students) AS Cnt FROM courses C, subscription S WHERE C.lecturer = Calders

### Chapter 13: Query Processing. Basic Steps in Query Processing

Chapter 13: Query Processing! Overview! Measures of Query Cost! Selection Operation! Sorting! Join Operation! Other Operations! Evaluation of Expressions 13.1 Basic Steps in Query Processing 1. Parsing

### 2 using read and write operations. A schedule is called correct" if we can find a serial schedule that is equivalent" to it. Given a set of transactio

1 1. CONCURRENCY CONTROL CS 242: Operating Systems Transactions Prasun Dewan The synchronization primitives we have seen so far are not as high-level as we might want them to be since they require programmers

### Chapter 15 : Concurrency Control

Chapter 15 : Concurrency Control Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Outline Lock-Based Protocols Timestamp-Based Protocols Validation-Based Protocols Multiple

### 9. Transaction Processing Concepts

ECS-165A WQ 11 164 9. Transaction Processing Concepts Goals: Understand the basic properties of a transaction and learn the concepts underlying transaction processing as well as the concurrent executions

### Relational Query Languages

Relational Query Languages Universidad de Concepción, 2014 (Slides adapted from Loreto Bravo, who adapted from Werner Nutt who adapted them from Thomas Eiter and Leonid Libkin) Bases de Datos II 1 Queries

### Database Management System Dr.S.Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Dr.S.Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 28 Recovery Mechanisms II Hello and welcome. In the previous session

### Overview. Overview of Transaction Management. Definition of a transaction. What is a transaction? Chapter 16

1 2 Overview Overview of Transaction Management Chapter 16 Transactions and the atomicity concept The so-called ACID principle Backup and recovery mechanisms» the types of failures that may occur» describe

### Database System Recovery

Database System Recovery Outline 1. Introduction 2. DB Recovery Model 3. Recovery Manager 4. Log-based Recovery 5. Media Failure 6. Shadow Paging 1. Introduction Transaction - The execution of a program

### Introduction to Database Management Systems

Database Administration Transaction Processing Why Concurrency Control? Locking Database Recovery Query Optimization DB Administration 1 Transactions Transaction -- A sequence of operations that is regarded

### SQL: Basic concepts. SQL operates with tables, so the first thing to do is create tables. Syntax:

SQL: Basic concepts SQL operates with tables, so the first thing to do is create tables. Syntax: CREATE TABLE ( type,..., type>) For example: CREATE TABLE Movies (title char(20),

### Transactions and the Internet

Transactions and the Internet Week 12-13 Week 12-13 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints and SQL

### David M. Kroenke and David J. Auer Database Processing:

David M. Kroenke and David J. Auer Database Processing: Fundamentals, Design, and Implementation Chapter Nine: Managing Multiuser Databases 9-1 Chapter Objectives To understand the need for, and importance

### Module 3 (14 hrs) Transactions : Transaction Processing Systems(TPS): Properties (or ACID properties) of Transactions Atomicity Consistency

Module 3 (14 hrs) Transactions : A transaction is a logical unit of program execution It is a combination of database updates which have to be performed together It is a logical unit of work. It is a unit

### CSC 443 Database Management Systems. Databases

CSC 443 Database Management Systems Lecture 2 Databases: The Big Picture Databases There are three different types of databases: Hierarchical databases Network databases Relational databases We are particularly

### Chapter 14: Recovery System

Chapter 14: Recovery System Chapter 14: Recovery System Failure Classification Storage Structure Recovery and Atomicity Log-Based Recovery Remote Backup Systems Failure Classification Transaction failure

### Query Optimization. Query Optimization. Optimization considerations. Example. Interaction of algorithm choice and tree arrangement.

COS 597: Principles of Database and Information Systems Query Optimization Query Optimization Query as expression over relational algebraic operations Get evaluation (parse) tree Leaves: base relations

### VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203.

VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : II / III Section : CSE - 1 & 2 Subject Code : CS 6302 Subject Name : Database

### Concurrency control. Concurrency problems. Database Management System

Concurrency control Transactions per second (tps) is the measure of the workload of a operational DBMS; if two transactions access concurrently to the same data there is a problem: the module who resolve

### Q4. What are data model? Explain the different data model with examples. Q8. Differentiate physical and logical data independence data models.

FAQs Introduction to Database Systems and Design Module 1: Introduction Data, Database, DBMS, DBA Q2. What is a catalogue? Explain the use of it in DBMS. Q3. Differentiate File System approach and Database

### Chapter 20: Advanced Transaction Processing

Chapter 20: Advanced Transaction Processing Remote Backup Systems Transaction-Processing Monitors High-Performance Transaction Systems Long-Duration Transactions Real-Time Transaction Systems Weak Levels

### Database Concurrency Control and Recovery. Simple database model

Database Concurrency Control and Recovery Pessimistic concurrency control Two-phase locking (2PL) and Strict 2PL Timestamp ordering (TSO) and Strict TSO Optimistic concurrency control (OCC) definition

### PART- B 1. Compare and contrast the merits and demerits of database system over file system.

CS2255 Database Management Systems Question bank UNIT I 1. What is Database Management System? 2. Define database. 3. Give some of the applications of database. 4. List the advantages of database system.

### Chapter 10. Backup and Recovery

Chapter 10. Backup and Recovery Table of Contents Objectives... 1 Relationship to Other Units... 2 Introduction... 2 Context... 2 A Typical Recovery Problem... 3 Transaction Loggoing... 4 System Log...

### CMPT-454 Fall 2009 Instructor: Martin Ester TA: Yi Liu. Solution Assignment 5

CMPT-454 Fall 2009 Instructor: Martin Ester TA: Yi Liu Solution Assignment 5 Total marks: 200 (20 % of the assignments) Due date: December 2, 2009 Problem 5.1 (50 marks) For each of the following schedules,

### Recovery and the ACID properties CMPUT 391: Implementing Durability Recovery Manager Atomicity Durability

Database Management Systems Winter 2004 CMPUT 391: Implementing Durability Dr. Osmar R. Zaïane University of Alberta Lecture 9 Chapter 25 of Textbook Based on slides by Lewis, Bernstein and Kifer. University

### DATABASE DESIGN - 1DL400

DATABASE DESIGN - 1DL400 Spring 2015 A course on modern database systems!! http://www.it.uu.se/research/group/udbl/kurser/dbii_vt15/ Kjell Orsborn! Uppsala Database Laboratory! Department of Information

### Steps in Query Processing Query Query Parser Parsed query. Query Evaluation and Optimization. An Overview. Plan Generator

Query Evaluation and Optimization An Overview Web Forms Application FEs SQL Interface Plan Executor Operator Evaluator Parser Optimizer Query Evaluation Engine Concurrency Control Transaction Manager Lock

### Announcements. Transaction Processing: Recovery. Review. Execution model. Naïve approach. Failures

Announcements 2 Transaction Processing: Recovery CPS 216 Advanced Database Systems Homework #4 due in 7 days (April 23) Recitation session this Friday (April 18) Homework #4 Q&A Project demo period starting

### Transfer 500. Account A Fred Bloggs 500 Account B Sue Smith 0 Account B Sue Smith 500

Transaction Processing Recovery & Concurrency Control What is a transaction A transaction is the basic logical unit of execution in an information system. A transaction is a sequence of operations that

### Relational Algebra The Relational Algebra and Relational Calculus. Relational Query Languages

The Relational Algebra and Relational Calculus Relational Algebra Slide 6-2 Relational Query Languages Query languages Allow manipulation and retrieval of data Not like programming languages Not intend

### Database Management System

Database Management System Normalization (Unit - IV) NORMALIZATION While designing a database out of an entity relationship model, the main problem existing in that raw database is redundancy. Redundancy

### Query Processing + Optimization: Outline

Query Processing + Optimization: Outline Operator Evaluation Strategies Query processing in general Selection Join Query Optimization Heuristic query optimization Cost-based query optimization Query Tuning

### CSE 562 Database Systems

UB CSE Database Courses CSE 562 Database Systems CSE 462 Database Concepts Introduction CSE 562 Database Systems Some slides are based or modified from originals by Database Systems: The Complete Book,

### Programming Interface: JDBC/ODBC. Applications View of a Relational Database Management (RDBMS) System

Applications View of a Relational Database Management (RDBMS) System Applications:. Persistent data structure Large volume of data Independent from processes using the data High-level programming interface

### CSCI Design of finternet Protocols: Database Recovery George Blankenship. Database Recovery George Blankenship 1

CSCI 6434 Design of finternet Protocols: Database Recovery George Blankenship Database Recovery George Blankenship 1 Outline Protocol functions Protocol layers Service definitions ISO/OSI model TCP/IP

### ! Volatile storage: ! Nonvolatile storage:

Chapter 17: Recovery System Failure Classification! Failure Classification! Storage Structure! Recovery and Atomicity! Log-Based Recovery! Shadow Paging! Recovery With Concurrent Transactions! Buffer Management!

### The Database Language SQL (iv)

ICS 321 Spring 2011 The Database Language SQL (iv) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/16/2011 Lipyeow Lim -- University of Hawaii at Manoa

### Keywords: Distributed Database, Distributed Design, Fragmentation, Replication, Allocation, Concurrency control, Transaction

Volume 3, Issue 7, July 2013 ISSN: 2277 128X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Concurrency Control

### Transaction Processing Monitors

Chapter 24: Advanced Transaction Processing! Transaction-Processing Monitors! Transactional Workflows! High-Performance Transaction Systems! Main memory databases! Real-Time Transaction Systems! Long-Duration

### Data Management in the Cloud

Data Management in the Cloud Ryan Stern stern@cs.colostate.edu : Advanced Topics in Distributed Systems Department of Computer Science Colorado State University Outline Today Microsoft Cloud SQL Server

### Distributed Databases Query Optimisation. TEMPUS June, 2001

Distributed Databases Query Optimisation TEMPUS June, 2001 1 Topics Query processing in distributed databases Localization Distributed query operators Cost-based optimization 2 Decomposition Query Processing

### CS 245 Final Exam Winter 2013

CS 245 Final Exam Winter 2013 This exam is open book and notes. You can use a calculator and your laptop to access course notes and videos (but not to communicate with other people). You have 140 minutes

### SQL Query Evaluation. Winter 2006-2007 Lecture 23

SQL Query Evaluation Winter 2006-2007 Lecture 23 SQL Query Processing Databases go through three steps: Parse SQL into an execution plan Optimize the execution plan Evaluate the optimized plan Execution

### Transaction Management

Transaction Management Transactions are units of work that must be executed atomically and (seemingly) in isolation from other transactions Their effects should be durable: no completed work should be

### Transactions and Concurrency Control. Goals. Database Administration. (Manga Guide to DB, Chapter 5, pg 125-137, 153-160) Database Administration

Transactions and Concurrency Control (Manga Guide to DB, Chapter 5, pg 125-137, 153-160) 1 Goals Database Administration Concurrency Control 2 Database Administration All large and small databases need

### Journal of Environmental Science, Computer Science and Engineering & Technology

JECET; March 2015-May 2015; Sec. B Vol.4.No.2, 183-190. E-ISSN: 2278 179X Research Article Journal of Environmental Science, Computer Science and Engineering & Technology An International Peer Review E-3

### Chapter 16: Recovery System

Chapter 16: Recovery System Failure Classification Failure Classification Transaction failure : Logical errors: transaction cannot complete due to some internal error condition System errors: the database

### Database 2 Lecture II. Alessandro Artale

Free University of Bolzano Database 2. Lecture II, 2003/2004 A.Artale (1) Database 2 Lecture II Alessandro Artale Faculty of Computer Science Free University of Bolzano Room: 221 artale@inf.unibz.it http://www.inf.unibz.it/

### Chapter 17: Recovery System

Chapter 17: Recovery System Database System Concepts See www.db-book.com for conditions on re-use Chapter 17: Recovery System Failure Classification Storage Structure Recovery and Atomicity Log-Based Recovery

### Piazza. Stellar. Github. this class is about database management systems (system for creating, manipulating, accessing a database)

Sam Madden TAs: Cheng Chen, Yi Lu http://db.csail.mit.edu/6.830/ Readings in Database Systems Database Management Systems Database Structured data collection Records Relationships Database management system

### COS 318: Operating Systems

COS 318: Operating Systems File Performance and Reliability Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall10/cos318/ Topics File buffer cache

### Database System Concepts

Chapter 14: Optimization Departamento de Engenharia Informática Instituto Superior Técnico 1 st Semester 2009/2010 Slides (fortemente) baseados nos slides oficiais do livro c Silberschatz, Korth and Sudarshan.

### Homework 2: Query Processing/Optimization, Transactions/Recovery (due October 6 th, 2014, 2:30pm, in class hard-copy please)

Virginia Tech. Computer Science CS 5614 (Big) Data Management Systems Fall 2014, Prakash Homework 2: Query Processing/Optimization, Transactions/Recovery (due October 6 th, 2014, 2:30pm, in class hard-copy

### CSE 444 Practice Problems. Query Optimization

CSE 444 Practice Problems Query Optimization 1. Query Optimization Given the following SQL query: Student (sid, name, age, address) Book(bid, title, author) Checkout(sid, bid, date) SELECT S.name FROM

Goals Managing Multi-User Databases Database Administration Concurrency Control (Kroenke, Chapter 9) 1 Kroenke, Database Processing 2 Database Administration All large and small databases need database

### CS 220 Relational Algebra 2/3/2015

CS 220 Relational Algebra 2/3/2015 Relational Query Languages Query = retrieval program Language examples: Theoretical: 1. Relational Algebra 2. Relational Calculus a. tuple relational calculus (TRC) b.

### Part I: Entity Relationship Diagrams and SQL (40/100 Pt.)

Part I: Entity Relationship Diagrams and SQL (40/100 Pt.) Q.1.1) Translate the following E-R Schema to SQL-DDL tables using the CREATE Table Statement and check constraints, if needed: LatinName EnglishName