Currently there are some query optimization techniques exists in the research field, but I would like to test those techniques and propose my technique which can add more energy to the sensor node..
You could look into the SNEE system (Sensor NEtwork Engine) which does stream query processing. TinyDB and AnduIN are other sensor network query processors.
The SNEE system can be programmed to work with the avrora or tossim WSN simulators (allowing you to run simulations without hardware) If you desire hardware, SNEE works with telos b and mica micaz motes.
there are other simulators out there ns2 and ns3 (or matlab) but SNEE itself cannot run on such things. TinyDB and AnduIN also compile to tossim and avrora.
testing query optimisation techniques is difficult, i forward you to some SNEE papers that test optimisation of executing query plans (so you can get a feel of what you need to do to produce a research paper in the field).