We consider three
possible plans: in the first, the magnetometer and accelerometer are sampled
before either selection is applied. In the second, the magnetometer is sampled
and the selection over its reading (which we call Smag) is applied before the
accelerometer is sampled or filtered. In the third plan, the accelerometer is
sampled first and its selection (Saccel) is applied before the magnetometer is
sampled.
We compared the costs of these three plans, and, as expected, found that
the first was always more expensive than the other two. More interestingly,
the second can be an order of magnitude more expensive than the third, when
Saccel is much more selective than Smag. Conversely, when Smag is highly
selective, it can be cheaper to sample the magnetometer first.
Similarly, we note that there are certain kinds of aggregate functions where
the same kind of interleaving of sampling and processing can also lead to a
performance savings. Consider the query:
320
Chapter 12 Data Management in Sensor Networks
SELECT MAX(light)
FROM sensors
WHERE mag > x
SAMPLE INTERVAL 8s
In this query, the maximum of eight seconds worth of light readings will
be computed, but only light readings from sensors whose magnetometers read
greater than x will be considered. Interestingly, it turns out that, unless the x
predicate is very selective, it will be cheaper to evaluate this query by checking
to see if each new light reading is greater than the previous reading and then
applying the selection predicate over mag, rather than first sampling mag.
Pages:
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515