- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
The Memo Exploring Multiple Plans Ef ciently in Visual Basic .NET
The Memo Exploring Multiple Plans Ef ciently UPC Symbol Maker In VB.NET Using Barcode generation for Visual Studio .NET Control to generate, create UCC - 12 image in VS .NET applications. www.OnBarcode.comGS1 - 12 Reader In Visual Basic .NET Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET applications. www.OnBarcode.comThe core structure of the Query Optimizer is the Memo. This structure helps store the result of all the rules that are run in the Query Optimizer, and it also helps guide the search of possible plans to nd a good plan quickly and avoid searching a sub-tree more than once. This speeds up the compilation process and reduces the memory requirements. In effect, this allows the Query Optimizer to run more advanced optimizations compared to other optimizers without a similar mechanism. Although this structure is internal to the Query Optimizer, this section describes its basic operations so that you can better understand the way that the Query Optimizer selects a plan. The Memo stores operators from a query tree and uses logical pointers to represent the edges of that tree. If we consider the query SELECT * FROM (A INNER JOIN B ON A.a=B.b) AS D INNER JOIN C ON D.c=C.c, this can be drawn as a tree, as seen in Figure 8-16. Create Barcode In Visual Basic .NET Using Barcode encoder for VS .NET Control to generate, create barcode image in .NET applications. www.OnBarcode.comRead Bar Code In Visual Basic .NET Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comMicrosoft SQL Server 2008 Internals
UPC A Creation In C# Using Barcode creation for VS .NET Control to generate, create UPC-A Supplement 2 image in VS .NET applications. www.OnBarcode.comMake UPC-A In Visual Studio .NET Using Barcode printer for ASP.NET Control to generate, create UPC Symbol image in ASP.NET applications. www.OnBarcode.comJoin (D.c=C.c) Generating UPC Symbol In .NET Framework Using Barcode generation for Visual Studio .NET Control to generate, create Universal Product Code version A image in .NET framework applications. www.OnBarcode.comDrawing GTIN - 128 In VB.NET Using Barcode creation for Visual Studio .NET Control to generate, create EAN128 image in VS .NET applications. www.OnBarcode.comJoin (A.a=B.b) QR Maker In VB.NET Using Barcode creation for VS .NET Control to generate, create QR image in .NET framework applications. www.OnBarcode.comCode-39 Drawer In VB.NET Using Barcode maker for VS .NET Control to generate, create Code-39 image in .NET framework applications. www.OnBarcode.comGet (C) Making ECC200 In Visual Basic .NET Using Barcode generation for .NET Control to generate, create Data Matrix image in Visual Studio .NET applications. www.OnBarcode.comCreate Rationalized Codabar In Visual Basic .NET Using Barcode encoder for .NET Control to generate, create 2 of 7 Code image in .NET applications. www.OnBarcode.comGet (A) Data Matrix ECC200 Drawer In None Using Barcode creator for Font Control to generate, create Data Matrix 2d barcode image in Font applications. www.OnBarcode.comEncoding GTIN - 128 In .NET Framework Using Barcode creator for Reporting Service Control to generate, create USS-128 image in Reporting Service applications. www.OnBarcode.comGet (B) UCC-128 Generation In None Using Barcode maker for Font Control to generate, create GS1 128 image in Font applications. www.OnBarcode.comDenso QR Bar Code Generation In .NET Framework Using Barcode printer for Reporting Service Control to generate, create QR-Code image in Reporting Service applications. www.OnBarcode.comFIGURE 8-16 Tree of a three-table join
Creating GS1 DataBar In Java Using Barcode generation for Java Control to generate, create GS1 DataBar Expanded image in Java applications. www.OnBarcode.comMatrix 2D Barcode Creation In Java Using Barcode drawer for Java Control to generate, create 2D Barcode image in Java applications. www.OnBarcode.comThe same query stored in the Memo can be seen in Figure 8-17. Code 128 Drawer In Java Using Barcode maker for Java Control to generate, create Code 128B image in Java applications. www.OnBarcode.comQR-Code Generation In None Using Barcode creation for Microsoft Word Control to generate, create QR Code JIS X 0510 image in Microsoft Word applications. www.OnBarcode.com(Root) Group 4: 0 Join 3 2 Group 3: 0 Join 0 1 Group 2: 0 Table C Group 1: 0 Table B Group 0: 0 Table A FIGURE 8-17 Initial Memo layout for a three-table join
The Memo is made up a series of groups. When the Memo is rst populated, each operator is put into its own group. The references between operators are changed to be references to other groups in the Memo. In this model, it is possible to store multiple alternatives that yield the same result in the same group in the Memo. With this change, it is possible to search for the best sub-tree independently of what exists in higher-level groups in the Memo. Logical properties are stored within each memo group, and every additional entry in a group can share the property structure for that group with the initial alternative. One type of alternative explored by the Query Optimizer is join associativity. [(A join B) join C)] is equivalent to [A join (B join C)]. After this transformation is considered by the Query Optimizer, Figure 8-18 describes the updated Memo structure. (The bold sections are new.) 8 Group 5: 0 Join 1 2 (Root) Group 4: 1 Join 0 5 0 Join 3 2 Group 3: 0 Join 0 1 Group 2: 0 Table C Group 1: 0 Table B Group 0: 0 Table A The Query Optimizer
FIGURE 8-18 Three-table Memo after the join associativity rule has been applied
Notice how the new alternative ts into a structure. (B join C) that has not been previously seen in the Memo, so a new group is created that then references the existing groups for B and C. This representation saves a lot of memory when considering multiple possible query plans, and it makes it possible for the Query Optimizer to know if it has previously considered a section of the search space so that it can avoid doing that work again. (A join C) would be another valid alternative, though it is not shown. Rules are the mechanisms that allow the Memo to explore new alternatives during the optimization process. The join associativity example is implemented as an optimization rule that matches a speci c pattern and then creates a new alternative that is equivalent to the rst one (returns the same result for that portion of the query). The result of a rule, by de nition, can go into the same group as the root of the original pattern. An optimization search pass is split into two parts. In the rst part of the search, exploration rules match logical trees and generate new, equivalent alternative logical trees that are inserted into the Memo. Implementation rules run next, generating physical trees from the logical trees. Once a physical tree has been generated, it is evaluated by the costing component to determine the cost for this query tree. The resulting cost is stored in the Memo for that alternative. When all physical alternatives and their costs are generated for all groups in the Memo, the Query Optimizer nds the one query tree in the Memo that has the lowest cost and copies that into a stand-alone tree. The selected physical tree is very close to the showplan form of the tree. The optimization process is optimized further by using multiple search passes, separating the rules based on cost and how likely they are to be useful. There are three phases, and each phase runs a set of exploration and implementation rules. The phases are con gured to make small queries optimize quickly and to make more expensive queries consider more aggressive rewrite rules that may take longer to compile. For example, index matching is performed in the rst phase, whereas the matching of index view is generally not performed until a later stage. The Query Optimizer can quit optimization at the end of a phase if a suf ciently good
|
|