Database-expression computing

Source: Internet
Author: User

An SQL statement like this:

 
Select * from account R where balance <2500 join customer s on R. Customer-name = S. Name

How can an expression contain multiple operations?

One method is to execute an operation in a certain order, and the result of each calculation isMaterializedTo a temporary relationship for future use. The cost of physical computing includes the cost of all operations and the cost of writing intermediate results back to the disk. Disk I/O costs a lot.

Another method isAssembly LineWhen multiple operations are executed at the same time, one operation result is passed to the next operation without being saved to the temporary relationship. As shown in the example, the left-side input of the connection operation comes from the pipeline. Because it is the pipeline Input, the input required for processing the connection operation cannot be obtained all at once. This limits the connections that can be used.AlgorithmFor example, it cannot be used before the input is sorted. Nested loop indexes can be used. A disk access is required for every tuples in the input link of the pipeline. The cost is Nr * HTS, and HTS is the index height on S. If the ing method is used and the hash connection is used, the execution result is 3 (Br + BS). The cost of writing the relational R is Br. When Nr is much larger than 4br + 3bs, the cost of the materialized method is small. If the input tuples in the pipeline are sorted by Connection Properties and the connection condition is equivalent connection, you can also use the merge connection. If both inputs are assembly line inputs and their equivalent connections are sorted, you can use the assembly line connection algorithm:

While not Doner or ont dones do

Begin

If the queue is empty, wait until the queue is not empty;

T = the first item in the queue;

If t = endr, then Doner = true;

Else if T = ends then dones = true;

Else if t belongs to the input relation R then

Begin

R = r branch | T |;

Result = result lost (T connected to S );

End

Else

Begin

S = s bytes | T |;

Result = result lost (T connected to S );

End

End

The two links can be queued for processing in the same queue.

For complex join operations, a good sequence of Join Operations is important to reduce the size of temporary results.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.