XML Query Optimizations in the Presence of Side Effects ======================================================= Recently, several initiatives are proposing to extend XQuery not only with updates, but also with more general forms of side effects. Some of the extensions are essential to facilitate the development of complex XML-based Web applications (grid resource allocation, XML scripting etc.) This is an important departure from traditional database languages, in which there is a strong separation between updates and queries. One of the reason for this separation is that lack of support for side-effects in database algebras and compilers. The main contribution of our work is the design and implementation of a database algebra with side effects. This algebra is used to compile several recently proposed XML languages, including the W3C XQuery Update facility, and XQueryP, a procedural extension to XQuery. We show how some of the most important query optimizations (such as join detection and query unnesting) can be recovered.