Firebird 2.5 Language ReferenceFirebird 2.5 Language Reference → Monitoring Tables
Firebird Firebird Prev: RDB$VIEW_RELATIONSFirebird 2.5 Language ReferenceUp: Firebird 2.5 Language ReferenceNext: MON$ATTACHMENTS

Appendix E: Monitoring Tables

Table of Contents

MON$ATTACHMENTS
Using MON$ATTACHMENTS to Kill a Connection
MON$CALL_STACK
MON$CONTEXT_VARIABLES
MON$DATABASE
MON$IO_STATS
MON$MEMORY_USAGE
MON$RECORD_STATS
MON$STATEMENTS
Using MON$STATEMENTS to Cancel a Query
MON$TRANSACTIONS

The Firebird engine can monitor activities in a database and make them available for user queries via the monitoring tables. The definitions of these tables are always present in the database, all named with the prefix MON$. The tables are virtual:  they are populated with data only at the moment when the user queries them. That is also one good reason why it is no use trying to create triggers for them!

The key notion in understanding the monitoring feature is an activity snapshot. The activity snapshot represents the current state of the database at the start of the transaction in which the monitoring table query runs. It delivers a lot of information about the database itself, active connections, users, transactions prepared, running queries and more.

The snapshot is created when any monitoring table is queried for the first time. It is preserved until the end of the current transaction to maintain a stable, consistent view for queries across multiple tables, such as a master-detail query. In other words, monitoring tables always behave as though they were in SNAPSHOT TABLE STABILITY (“consistency”) isolation, even if the current transaction is started with a lower isolation level.

To refresh the snapshot, the current transaction must be completed and the monitoring tables must be re-queried in a new transaction context.

Access Security

[Warning] Warning

In a highly loaded environment, collecting information via the monitoring tables could have a negative impact on system performance.

Table E.1. List of Monitoring Tables

System Table Contents
MON$ATTACHMENTS Information about active attachments to the database
MON$CALL_STACK Calls to the stack by active queries of stored procedures and triggers
MON$CONTEXT_VARIABLES Information about custom context variables
MON$DATABASE Information about the database to which the CURRENT_CONNECTION is attached
MON$IO_STATS Input/output statistics
MON$MEMORY_USAGE Memory usage statistics
MON$RECORD_STATS Record-level statistics
MON$STATEMENTS Statements prepared for execution
MON$TRANSACTIONS Started transactions


Prev: RDB$VIEW_RELATIONSFirebird 2.5 Language ReferenceUp: Firebird 2.5 Language ReferenceNext: MON$ATTACHMENTS
Firebird 2.5 Language ReferenceFirebird 2.5 Language Reference → Monitoring Tables