A database is queried with on demand database query reduction A query
document includes global variables selectively set off by first tags
identifying a first global variable as a complete replacement variable
and by second tags identifying a second global variable as a complete
removal string. An agent is provided for building from the query document
an expanded query by replacing any variables set off by first tags with
runtime strings, setting off any unions in the query document, and
selectively replacing any variables set off by second tags and removing
the second tags without replacing variables set off by second tags.