1. A method for applying a query to an event stream, comprising: storing one or more event constraints; performing constraint aware complex event processing on the query and the event constraints; and optimizing the query at run time.