Query processing in the original TinyDB implementation works as follows. The query is input on the user’s PC, or basestation. This query is optimized to improve execution; currently, TinyDB only considers the order of selection predicates during optimization (as the existing version does not support joins). Once optimized, the query is translated into a sensor-network specific format and injected into the network via a gateway node. The query is sent to all nodes in the network using a simple broadcast flood (TinyDB also implements a form of epidemic query sharing which we do not discuss)