25.01.2015 Views

Cost-Based Optimization of Integration Flows - Datenbanken ...

Cost-Based Optimization of Integration Flows - Datenbanken ...

Cost-Based Optimization of Integration Flows - Datenbanken ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3 Fundamentals <strong>of</strong> Optimizing <strong>Integration</strong> <strong>Flows</strong><br />

In order to achieve control-flow awareness, we additionally need to take into account<br />

the path probabilities <strong>of</strong> (possibly hierarchically structured) Switch operators in the form<br />

<strong>of</strong> probabilities P (o i ) that an operator is executed. As a result, the costs <strong>of</strong> a sequence <strong>of</strong><br />

Selection operators are determined by<br />

C(P ) =<br />

=<br />

m∑<br />

(P (o i ) · |ds in (o i )|)<br />

i=1<br />

⎛<br />

⎞<br />

m∑ ∏i−1<br />

(<br />

⎝ P (oj ) · f oj + (1 − P (o j )) ) · |ds in (o 1 )| ⎠ ,<br />

i=1 j=1<br />

(3.23)<br />

where (P (o i ) · f oi + (1 − P (o i ))) denotes the effective operator selectivity. The order <strong>of</strong><br />

Selection operators is still optimal if f oi ≤ f oi+1 holds for all selective operators due to the<br />

conditional operator execution with P (o i ). However, the effective operator selectivity must<br />

be taken into account when evaluating following operators. If a Switch operator contains<br />

multiple Selection operators (in different paths), we reorder only the complete Switch<br />

operator according to the total effective operator selectivity P (o i ) · f oi + P (o j ) · f oj . The<br />

actual rewriting algorithm works as follows. First, we determine the selectivities <strong>of</strong> each<br />

individual operator. Second, we reorder the operators according to the given optimality<br />

condition. Third, we evaluate if the increased costs <strong>of</strong> additional non-selective operators<br />

(such as the Switch operator) are amortized by applying the selective operator earlier.<br />

While the normal selection reordering exhibits a time complexity <strong>of</strong> O(m log m) due to<br />

the simple sorting according to the selectivities, the control-flow aware selection reordering<br />

exhibits a time complexity <strong>of</strong> O(m 2 ) = O(m 2 + m log m) because after sorting, for each<br />

operator, we additionally evaluate all subsequent operators. In the following, we use an<br />

example to illustrate the importance <strong>of</strong> this control-flow aware rewriting.<br />

Example 3.13 (Selection Reordering). Assume a subplan P as illustrated in Figure 3.16(a)<br />

that contains four different Selection operators. Furthermore, assume the given monitored<br />

selectivities, path probabilities and an input cardinality <strong>of</strong> |ds in (o 1 )| = 1,000. For<br />

sake <strong>of</strong> simplicity the costs <strong>of</strong> a (hierarchically structured) Switch operator are computed<br />

by |ds in | and we use the abstract costs rather than the weighted costs for cost comparison.<br />

Then, the costs are determined as follows: C(P ) = 1,000+500+350+0.05·350+0.965·350 =<br />

[P(A)=0.9]<br />

f=0.5<br />

Selection (o1)<br />

[in: msg1, out: msg2]<br />

f=0.7<br />

Selection (o2)<br />

[in: msg2, out: msg3]<br />

Switch (o3)<br />

[in: msg3]<br />

f=0.4<br />

Selection (o8)<br />

[in: msg4, out: msg5]<br />

[P(B)=0.1]<br />

Switch (o5)<br />

[in: msg3] [P(D)=0.5]<br />

f=0.3<br />

Selection (o7)<br />

[in: msg3, out: msg4]<br />

[P(A)=0.9]<br />

Switch (o3)<br />

[in: msg3]<br />

f=0.4<br />

Selection (o8)<br />

[in: msg4, out: msg5]<br />

f=0.5<br />

Selection (o1)<br />

[in: msg5, out: msg2]<br />

f=0.7<br />

Selection (o2)<br />

[in: msg2, out: msg3]<br />

[P(B)=0.1]<br />

Switch (o5)<br />

[in: msg3] [P(D)=0.5]<br />

f=0.3<br />

Selection (o7)<br />

[in: msg3, out: msg4]<br />

[P(A)=0.9]<br />

f=0.4<br />

Selection (o8)<br />

[in: msg4, out: msg5]<br />

f=0.5<br />

Selection (o1)<br />

[in: msg5, out: msg2]<br />

f=0.7<br />

Selection (o2)<br />

[in: msg2, out: msg3]<br />

Switch (o3)<br />

[in: msg3]<br />

[P(B)=0.1]<br />

Switch (o5)<br />

[in: msg3] [P(D)=0.5]<br />

f=0.3<br />

Selection (o7)<br />

[in: msg3, out: msg4]<br />

(a) Plan P<br />

(b) Normal Selection Reordering<br />

(c) Aware Selection Reordering<br />

Figure 3.16: Example Control-Flow-Aware Selection Reordering<br />

68

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!