290 likes | 539 Views
Query Processing in Sensor Networks. 11/09/2006. Se Ho Park Hyun Ik Jang Frolin Rusu. W. Hong & S. Madden – Implementation and Research Issues in Query Processing for Wireless Sensor Networks, ICDE 2004. I. II. III. IV. V. VI. Introduction. Architecture. Data Model and Query Language.
E N D
Query Processing in Sensor Networks 11/09/2006 Se Ho Park Hyun Ik Jang Frolin Rusu W. Hong & S. Madden – Implementation and Research Issues in Query Processing for Wireless Sensor Networks, ICDE 2004
I II III IV V VI Introduction Architecture Data Model and Query Language Query Dissemination and Result Collection Query Processing Conclusions Outline
I II III IV V VI Introduction Architecture Data Model and Query Language Query Dissemination and Result Collection Query Processing Conclusions Outline
Introduction – Sensor Database SELECT MAX(mag) FROM sensors WHERE mag > thresh SAMPLE 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 Query, Trigger Data Sensor Network Query Processor
Architecture - overall TinyDB GUI JDBC TinyDB Client API DBMS PC side 0 Mote side TinyDB query processor 0 2 1 3 8 4 5 6 Sensor network 7
Architecture - mote Query reception Query processing Runtime Adaptation Catalog TinyOS sampling, communication TinyDB Root (gateway node) Distributed in Network Query processor Wireless Sensor networks
Architecture - server Client PC-Base station Query parsing Query optimization Query result storage and display Query Data Routing Tree
I II III IV V VI Introduction Architecture Data Model and Query Language Query Dissemination and Result Collection Query Processing Conclusions Outline
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
Query Language - TinySQL SELECT <aggregates>, <attributes> [FROM {sensors | <buffer>}] [WHERE <predicates>] [GROUP BY <expr>] [HAVING <predicates>] [SAMPLE PERIOD <const> | ONCE] [INTO <buffer>]
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)
TinySQL Example “Find the sensors in bright nests.” Sensors SELECTnodeid, nestNo, light FROMsensors WHERElight > 400 SAMPLE PRIOD1s FOR 2s Epoch nodeid nestNo light 0 1 17 455 0 2 25 389 1 1 17 422 1 2 25 405
Event-based Queries ON event SELECT … Run query only when interesting events happen Event examples Button pushed Message arrival Bird enters nest Analogous to triggers but events are user-defined
Query over Stored Data Named buffers in Flash memory Store query results in buffers Query over named buffers Analogous to materialized views Example: CREATE BUFFERname SIZE x (field1 type1, field2 type2, …) SELECTa1, a2 FROM sensorsSAMPLEPERIODdINTOname SELECTfield1, field2, …FROMnameSAMPLE PERIODd
I II III IV V VI Introduction Architecture Data Model and Query Language Query Dissemination and Result Collection Query Processing Conclusions Outline
Tree-based Routing Tree-based routing Used in: Query delivery Data collection In-network aggregation Q:SELECT … A Q R:{…} Q R:{…} Q B C Q Q R:{…} Q Q D R:{…} Q R:{…} Q Q Q F E Q
Basic Aggregation In each epoch: Each node samples local sensors once Generates partial state record (PSR) local readings readings from children Outputs PSR during assigned comm. interval At end of epoch, PSR for whole network output at root New result on each successive epoch 1 2 3 4 5
Illustration: Aggregation SELECT COUNT(*) FROM sensors Sensor # 1 Epoch 1 2 3 4 5 2 4 1 3 3 2 4 1 1 4 5 Interval 4 Interval #
Illustration: Aggregation SELECT COUNT(*) FROM sensors Sensor # 1 1 2 3 4 5 2 4 1 3 3 2 2 2 4 1 4 5 Interval 3 Interval #
Illustration: Aggregation SELECT COUNT(*) FROM sensors Sensor # 1 1 1 2 3 4 5 3 2 4 1 3 3 2 2 1 3 4 1 4 5 Interval 2 Interval #
Illustration: Aggregation SELECT COUNT(*) FROM sensors 5 Sensor # 1 1 2 3 4 5 2 4 1 3 3 2 2 1 3 4 1 5 4 5 Interval 1 Interval #
Illustration: Aggregation SELECT COUNT(*) FROM sensors Sensor # 1 1 2 3 4 5 2 4 1 3 3 2 2 1 3 4 1 5 1 4 1 5 Interval 4 Interval #
I II III IV V VI Introduction Architecture Data Model and Query Language Query Dissemination and Result Collection Query Processing Conclusions Outline
Inside TinyDB T:1, AVG: 225 T:2, AVG: 250 SELECT AVG(temp) WHERE light > 400 Results Queries Aggavg(temp) Filterlight > 400 Name: temp Time to sample: 50 uS Cost to sample: 90 uJ Calibration Table: 3 Units: Deg. F Error: ± 5 Deg F Get f: getTempFunc()… got(‘temp’) get (‘temp’) Tables Samples getTempFunc(…) Multihop Network Query Processor Schema TinyOS TinyDB
Acquisitional Query Processing (ACQP) TinyDB acquires AND processes data Could generate an infinite number of samples An acqusitional query processor controls when, where, and with what frequency data is collected! Versus traditional systems where data is provided a priori
ACQP: What’s Different? How should the query be processed? Sampling as a first class operation How does the user control acquisition? Rates or lifetimes Event-based triggers Which nodes have relevant data? Index-like data structures Which samples should be transmitted? Prioritization, summary, and rate control
Operator Ordering: Interleave Sampling + Selection At 1 sample / sec, total power savings could be as much as 3.5mW Comparable to processor! Correct ordering (unless pred1 is very selective and pred2 is not): Traditional DBMS (pred2) (pred1) (pred1) Costly mag light ACQP (pred2) (pred2) (pred1) Cheap light mag mag light • E(sampling mag) >> E(sampling light) 1500 uJ vs. 90 uJ SELECT light, mag FROM sensors WHERE pred1(mag) AND pred2(light) SAMPLE PERIOD 1s
Conclusions • Architecture • Data Model and Query Language • Query Dissemination and Result Collection • Query Processing