Upload
jean-miller
View
219
Download
0
Embed Size (px)
DESCRIPTION
Outline Introduction I I Architecture II Data Model and Query Language III Query Dissemination and Result Collection IV Query Processing V V Conclusions VI
Citation preview
W. Hong & S. Madden – Implementation and Research Issues in Query Processing for Wireless Sensor Networks, ICDE 2004
OutlineIntroductionI
ArchitectureII
Data Model and Query LanguageIII
Query Dissemination and Result CollectionIV
Query ProcessingV
ConclusionsVI
OutlineIntroductionI
ArchitectureII
Data Model and Query LanguageIII
Query Dissemination and Result CollectionIV
Query ProcessingV
ConclusionsVI
44
Introduction – Sensor Database
SELECT MAX(mag) FROM sensors WHERE mag > threshSAMPLE PERIOD 64ms
• High level abstraction:– Data centric programming– Interact with sensor network
as a whole– Extensible framework
• Under the hood:– Intelligent query processing:
query optimization, power efficient execution
– Fault Mitigation: automatically introduce redundancy, avoid problem areas
App
Sensor Network
Query Processor
Query, Trigger Data
55
Architecture - overall
TinyDB GUI
TinyDB Client API DBMS
Sensor network
TinyDB query
processor
0
4
0
1
5
2
6
3
7
JDBC
Mote side
PC side
8
66
Architecture - mote
TinyDB
Distributed in Network Query processor
Query reception
Query processing
Runtime Adaptation
CatalogTinyOS sampling,
communication
Root (gateway node)
Wireless Sensor networks
77
Architecture - server
Client PC-Base station
DataQuery
Query parsing
Query optimization Query result storage and display
Routing Tree
OutlineIntroductionI
ArchitectureII
Data Model and Query LanguageIII
Query Dissemination and Result CollectionIV
Query ProcessingV
ConclusionsVI
99
Data Model
• Entire sensor network as one single, infinitely-long logical table: sensors
• Columns consist of all the attributes defined in the network
• Typical attributes:– Sensor readings
– Meta-data: node id, location, etc.
– Internal states: routing tree parent, time-stamps, queue length, etc.
• Nodes return NULL for unknown attributes• On server, all attributes are defined in catalog.xml
1010
Query Language - TinySQL
SELECT <aggregates>, <attributes>[FROM {sensors | <buffer>}][WHERE <predicates>][GROUP BY <expr>][HAVING <predicates>][SAMPLE PERIOD <const> | ONCE][INTO <buffer>]
1111
Comparison with SQL
• Single table in FROM clause• No sub-queries• No column alias in SELECT clause• Only fundamental difference: SAMPLE
PERIOD clause• The result of query is a stream of values
(rather than single aggregate value)
1212
TinySQL Example
SELECTSELECT nodeid, nestNo, lightnodeid, nestNo, lightFROMFROM sensorssensorsWHEREWHERE light > 400light > 400SAMPLE PRIODSAMPLE PRIOD 1s 1s FORFOR 2s 2s
2
1
2
1
nodeinodeidd
405251
422171
389250
455170
lightlightnestNnestNoo
EpocEpochh
Sensors
“Find the sensors in bright nests.”
1313
Event-based Queries
• ON event SELECT …
• Run query only when interesting events happen
• Event examples- Button pushedButton pushed
- Message arrivalMessage arrival
- Bird enters nestBird enters nest
• Analogous to triggers but events are user-defined
1414
Query over Stored Data
• Named buffers in Flash memory• Store query results in buffers• Query over named buffers• Analogous to materialized views• Example:
- CREATE BUFFERCREATE BUFFER name SIZE x (field1 type1, field2 type2, …)name SIZE x (field1 type1, field2 type2, …)
- SELECTSELECT a1, a2 FROM sensorsa1, a2 FROM sensors SAMPLESAMPLE PERIODPERIOD dd INTOINTO namename
- SELECTSELECT field1, field2, …field1, field2, … FROMFROM namename SAMPLE PERIODSAMPLE PERIOD dd
OutlineIntroductionI
ArchitectureII
Data Model and Query LanguageIII
Query Dissemination and Result CollectionIV
Query ProcessingV
ConclusionsVI
1616
Tree-based Routing
• Tree-based routing- Used in:Used in:
– Query delivery – Data collection– In-network aggregation
A
B C
D
FE
Q:SELECT …
Q Q
Q
Q
Q
Q QQ
R:{…}
R:{…}
R:{…}
R:{…}
R:{…}
1717
Basic Aggregation
• In each epoch:- Each node samples local sensors onceEach node samples local sensors once- Generates Generates partial state record (PSR)partial state record (PSR)
– local readings – readings from children
- Outputs PSR during assigned Outputs PSR during assigned comm. intervalcomm. interval
• At end of epoch, PSR for whole network output at root
• New result on each successive epoch
1
2 3
4
5
1818
Illustration: Aggregation
1
2
3
14
4
54321
1
2 3
4
51
Sensor #
Inte
rval
#
Interval 4SELECT COUNT(*) FROM sensors
Epoch
1919
Illustration: Aggregation
1
2
23
14
4
54321
1
2 3
4
5
2
Sensor #Interval 3
SELECT COUNT(*) FROM sensors
Inte
rval
#
2020
Illustration: Aggregation
1
312
23
14
4
54321
1
2 3
4
5
31
Sensor #Interval 2
SELECT COUNT(*) FROM sensors
Inte
rval
#
2121
Illustration: Aggregation
51
312
23
14
4
54321
1
2 3
4
5
5
Sensor #Interval 1
Inte
rval
#
SELECT COUNT(*) FROM sensors
2222
Illustration: Aggregation
51
312
23
14
14
54321
1
2 3
4
51
Sensor #
SELECT COUNT(*) FROM sensors Interval 4
Inte
rval
#
OutlineIntroductionI
ArchitectureII
Data Model and Query LanguageIII
Query Dissemination and Result CollectionIV
Query ProcessingV
ConclusionsVI
2424
Inside TinyDB
TinyOSSchema
Query Processor
Multihop Network
Filterlight >
400get (‘temp’)
Aggavg(tem
p)
QueriesSELECT AVG(temp) WHERE light > 400
ResultsT:1, AVG: 225T:2, AVG: 250
Tables
Samples
got(‘temp’)Name: tempTime to sample: 50 uSCost to sample: 90 uJCalibration Table: 3Units: Deg. FError: ± 5 Deg FGet f : getTempFunc()…
getTempFunc(…)getTempFunc(…)
TinyDBTinyDB
2525
Acquisitional Query Processing (ACQP)
• TinyDB acquires AND processes data- Could generate an infinite number of samplesCould generate an infinite number of samples
• An acqusitional query processor controls - when, when,
- where, where,
- and with what frequency data is collected!and with what frequency data is collected!
• Versus traditional systems where data is provided a priori
2626
ACQP: What’s Different?
• How should the query be processed?- Sampling as a first class operationSampling as a first class operation
• How does the user control acquisition?- Rates or lifetimesRates or lifetimes- Event-based triggersEvent-based triggers
• Which nodes have relevant data?- Index-like data structuresIndex-like data structures
• Which samples should be transmitted?- Prioritization, summary, and rate controlPrioritization, summary, and rate control
2727
• E(sampling mag) >> E(sampling light)
1500 uJ vs. 90 uJ
Operator Ordering: Interleave Sampling + Selection
SELECT light, magFROM sensorsWHERE pred1(mag)AND pred2(light)SAMPLE PERIOD 1s
(pred1)
(pred2)
mag light
Traditional DBMS
At 1 sample / sec, total power savings could be as much as 3.5mW Comparable to processor!
(pred1)
(pred2)
mag
light
(pred1)
(pred2)
mag
lightACQP
Correct orderingCorrect ordering(unless pred1 is (unless pred1 is very very selective selective
and pred2 is not):and pred2 is not):
Cheap
Costly
2828
Conclusions
• Architecture
• Data Model and Query Language
• Query Dissemination and Result Collection
• Query Processing
Questions ?