Distributed Database Distributed Database Management Systems Management Systems
Distributed Database Distributed Database Management Systems Management Systems
Query Optimization
Dr. Eng. Haiyan HOUSROUM
Query Optimization
The number of relations in the query The number of operations to be performed The number of predicates applied The size of each relation in the query The order of operations to be performed, The existence of indexes The number of alternatives for performing each individual operation
Query Optimization
In a distributed system, there are other factors The fragmentation details for the relations The location of these fragments/tables in the system The speed of communication links connecting the sites in the system. The overhead associated with sending messages and the overhead associated with the local processing speed increase exponentially as the number of available alternatives increases. It is generally acceptable to merely try to find a good alternative execution plan for a given query, rather than trying to find the best alternative.
Query Optimization
Bank Database CUSTOMER (CID, CNAME, STREET, CCITY); BRANCH (BNAME, ASSETS, BCITY); ACCOUNT (A#, CID, BNAME, BAL); LOAN (L#, CID, BNAME, AMT); TRANSACTION (TID, CID, A#, Date, AMOUNT);
Computing Selection
No Index on R and Not Sorted (Sorted): Scan all disk blocks B+Tree index on R Simple predicates Complex predicates Hash Index on R
Computing Join
Nested-Loop Join Nested-Loop Join with Indexes Sort-Merge Join
Hybrid Shipping
Create LA_EMPS
AS SELECT * FROM EMP WHERE LOC = LA;
Create NY_EMPS
AS SELECT * FROM EMP WHERE LOC = NY;
Select Name
From EMP Where LOC = LA and Sal > 30,000.