A Cost-Space Approach to Distributed Query Optimization in Stream Based Overlays