Query statistics
- Last Updated: March 30, 2020
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
Query statistics provide information on the query as it extracts data from the database. That is, on the retrieval of records during the query. This information is intended to help you evaluate query performance.
For the purposes of gathering statistics, queries fall into either of two categories:
-
Pre-pass queries — Queries that build a result-list completely,
in one ABL statement, before going on to the next ABL statement.
The AVM builds the result-list at different times for different
types of queries. These queries include:
- Static and dynamic
queries that perform sorting or pre-fetching. (The AVM builds a
complete result-list only on the first
GET NEXTstatement orGET-NEXT()method executed.) - Static
PRESELECTstatements. The AVM builds a complete result-list on thePRESELECTstatement. FORstatements that sort on the client and build a list of results in a sort file. The AVM builds a complete result-list on theFOR EACHstatement.
- Static and dynamic
queries that perform sorting or pre-fetching. (The AVM builds a
complete result-list only on the first
-
Non-pre-pass queries — Queries that do not build a result-list
completely before executing the next ABL statement. These queries
include
FOR EACHstatements and queries that sort by an index, enabling the server to identify the next record from the index, without any sorting by the client.Between record retrievals, the client steps through ABL statements in an iterating block, for example, between a
FOR EACHand its correspondingENDstatement. In cases where the client is selecting the records, only fetches involving records that satisfy selection criteria iterate through the loop.
Query information logging logs different information depending on whether the query is a pre-pass query or a non-pre-pass query. Both pre-pass and non-pre-pass queries write statistics when the query is complete. A query is considered complete at the following points in the code:
- For
FORand staticPRESELECTstatements, at the end of the block (theENDstatement). Any statements that cause a premature exit from the block still result in end-of-block processing, and the logging of query statistics. - For static and dynamic queries, when the AVM closes the query.
The following are examples of when the AVM closes the query:
- On
a
CLOSE QUERYstatement orQUERY-CLOSE()method - On a
OPEN QUERYstatement orQUERY-OPEN()method if the query is already open - When the query goes out of scope, that is, the program containing the query exits
- When a program deletes a buffer used by a dynamically opened query
- On
a