We could record metadata about queries manualy in the xql files: what tables does this query depend on, what tables does this dml effect. Queries with no metadata would depend on/ivalidate all cache entries, but queries with dependency info could work smarter.