1. Trang chủ
  2. » Công Nghệ Thông Tin

Distributed Database Management Systems: Lecture 31

45 1 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Query Decomposition
Thể loại lecture
Định dạng
Số trang 45
Dung lượng 118,12 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Distributed Database Management Systems: Lecture 31. The main topics covered in this chapter include: query decomposition; steps in query processing; SQL query on distributed relations; optimized fragment query with communication operations;...

Trang 1

Distributed Database Management Systems

Lecture 31

Trang 2

In the previous lecture

• Basic Concepts of Query

Optimization

• QP in centralized and

Distributed DBs

Trang 3

In this Lecture

• Query Decomposition

• Its Phases

Trang 4

SQL Query on Distributed Relations

QUERY DECOMPOSITION GLOBALSCHEMAAlgebraic Query on Distributed

Relations

DATA LOCALIZATION FRAGMENTSCHEMAFragment Query

GLOBAL OPTIMIZATION STAT OFFRAGMENTSOptimized Fragment Query with

Communication Operations LOCAL

OPTIMIZATION SCHEMALOCAL

Optimized Local Query

Steps in Query Processing

Trang 7

1- Normalization

complex

Analysis (like compilers)

Clause

Trang 9

V into U and ^ into

V into U and ^ into or ⋈

.

Trang 10

• SELECT eName

FROM EMP, ASG

WHERE EMP.eNo = ASG.eNo AND ASG.pNo = ‘P1’

AND dur = 12 OR dur = 24

Trang 11

^ASG.pNo = ‘P1’ ^ dur = 24)

Trang 12

2- Analysis

• Reject incorrect ones

• Type incorrect

–Relations/attributes not exist

Trang 14

Query Graph

or operand relations

• Links represent joins or

projection (result node)

• Self join/select on

operand nodes

Trang 15

• Select eName, resp

FROM EMP, ASG, PROJ

WHERE EMP.eNo = ASG.eNo AND ASG.pNo = PROJ.pNo AND pName = ‘CAD/CAM’ AND dur ≥ 36

AND title = ‘Programmer’

Trang 16

Query Graph

RESULT EMP

Dur ≥ 36

ASG.pNo = PROJ.pNo

pName =

‘CAD/CAM’ resp

Trang 18

Semantically Incorrect

• Select eName, resp

FROM EMP, ASG, PROJ

WHERE EMP.eNo =ASG.eNo AND pName = ‘CAD/CAM’ AND dur ≥ 36

AND title = ‘Programmer’

Trang 19

Query Graph

RESULT EMP

Dur ≥ 36

pName =

‘CAD/CAM’ resp

Trang 20

3- Elimination of Redundancy

already used in views

• User mistake or this

replacement may contain

redundant predicates

rules

Trang 22

• Select title

FROM EMP

WHERE (title = ‘Prog’

AND ((not (title = ‘Prog’))

OR title = ‘Elect Engr’)

AND (not (title = ‘Elect Engr’)))

OR eName = ‘Saleem’

Trang 23

(false) v (false) v p3 = p3

Trang 27

steps-Query Tree

• Select eName

FROM EMP, ASG, PROJ

WHERE EMP.eNo = ASG.eNo AND ASG.pNo = PROJ.pNo

AND pName = ‘CAD/CAM’ AND (dur = 36 or dur = 24)

Trang 28

PROJ ASG EMP

Trang 29

(R x S) x T S x (R x T)

(R (R S) T ⋈ ⋈ S (R ⋈ ⋈ T)

Trang 30

3- Idempotency of unary Ops

i) A’( A”(R)) A’(R)

ii) σp1(A1)p2(A2) (R))

σp1(A1) p2(A2)

(R)-4- Commuting selection with projection

A1, ….,An ( p(Ap)(R)) A1,

….,An (( p(Ap) A1, ….,An, Ap

Trang 32

• Many eq query trees

can be generated

• Comparing all such

trees to select best is not feasible

• Heuristic is applied

Trang 33

1 Separation of Unary Ops

relation grouped together

binary ops

Trang 34

ASN PROJ EMP

x

⋈ pNo^eNo

(pName = ‘CAD/CAM’)^ ( dur = 12 v dur = 24)^ eName ’Saleem’

eName

Trang 35

PROJ ASG EMP

pNo, eName eName

Trang 36

• This concludes QP that

comprises 4 steps

• Now we move to the

second phase of Query Optimization; Data

Localization of DD

Trang 37

• QD at global level, this

phase transform into

local ones

• A Nạve rule…

• However, it won’t be

an efficient one

Trang 38

Reduction During Data

Localization

Trang 39

Example Schema

Trang 40

• Reduction with Selection

• Rule 1:

pi (Rj) = Ø if x in R ∀ j: (pi(x) ^ pj(x))

• That is, there exist

conflicting predicates

Trang 41

• Select * from EMP where

Trang 42

Reduction on Join

• Distributing joins over

unions and avoiding

unnecessary joins

• (R1UR2) ⋈ R3= (R1 ⋈

R3) U (R2UR3)

Trang 43

• Rule2:

• Ri⋈Rj = Ø if x in R∀ iand y in R∀ j: (pi(x) ^

pj(x))

• Useless joins can be

determined viewing the join predicates

Trang 44

• Remember! Reduced query

is not always better We

have to be watchful

• ASG1 = eNo ≤ ‘E3’ (ASG)ASG1 =

• ASG2 = ’eNo > ‘E3’ (ASG).ASG2 =

Trang 45

–θ {=, <, ≠ ≤, >, ≥} ∈ ∈ ∀– ←Ø ⇒ ⋉ ⋈ ∪ ^

Ngày đăng: 05/07/2022, 13:40

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN