What are 'active queries'?

The main purpose of an active query is for a client to monitor information in the server, and be told when data changes without having to poll. In fact, it is better than that, since the client is not just told that a change has occurred, but is told just enough information to bring it up to date.

When an active query is established, the client is given the initial results, and then the server sets up internal triggers, so that whenever anything occurs in the database that would invalidate the previous results, the query manager is told. At the end of the transaction in which the change or changes occurred, assuming no rollback occurs the query manager calculates what information has to be sent to the client, which is then sent through to the client as a 'delta', a batch of changes. The internal trigger mechanism in the core database engin is the essential feature that means no time is wasted re-evaluating queries that have not been effected by a given transaction.

The query manager has two mechanisms for ensuring that the communications traffic is not excessive. Firstly, if a client is running slow and not able to keep up with all the deltas it receives, the server needs to control the number of deltas sent. This is done by only sending a delta when the previous one had been acknowledged; if many relevant transactions had occurred in the meantime, the client is only told about the current state, not any intermediate ones.

The second performance enhancement is the ability for the client to specify a bandwidth limit when the query is established. If updating a mimic diagram, for example, viewers will not be able to absorb too-frequent updates, so it makes sense to limit the delta to at most, say 10 per second. In fact, the limit is expressed not as a frequency - which might be taken as implying some form of polling - but as a time period: once one delta has been sent, further deltas are blocked for that interval or until the client acknowledges the outstanding delta, whichever is later.

This topic was listed under the following topic areas:

  • general
  • transactional model