1. A method for operating a database, the method comprising: receiving a first query, the first query comprising a first component indicating a criteria for generating a materialized query table from the database, and a second component comprising a condition for generating a reference value indicating a state of one or more items in the database, wherein the first component of the first query is generated using a table generating instruction of a query language, and the second component is generated by modifying a field of the table generating instruction to specify the condition for generating the reference value, and wherein the condition comprises a user defined query, and both the first query and the user defined query are generated using a same query language; generating, by executing the first component in response to receiving the query, the materialized query table from the database, the materialized query table having a set of one or more data items (set of data items) satisfying the criteria; generating, by executing the second component in response to receiving the query, a first reference value, wherein: executing the first component uses a first quantity of computing resources, and executing the second component uses a second quantity of computing resources, the second quantity of computing resources being less than the first quantity of computing resources; receiving, subsequent to generating the first reference value, a second query for retrieving a data item from the set of data items; generating, by executing the second component in response to receiving the second query, a second reference value; determining whether the first reference value is equal to the second reference value; updating the materialized query table when the first reference value is not equal to the second reference value; providing, subsequent to the updating, the data item from the updated materialized query table when the first reference value is equal to the second reference value; generating, by executing the second component in response to updating the materialized query table, a third reference value to replace the first reference value; and wherein: the query language is a Structured Query Language query language, the table generating instruction is a CREATE TABLE instruction, the field is a MAINTAINED BY USER field, and the condition is specified using a SELECT statement.