Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am working with a Firebird 2.1.1 database and I started reading about the Monitoring tables.

I am trying to see somehow in real-time what queries does each client performs in the database.

I had a look at the MON$STATEMENTS table but it does not provide much info. I would have expected more content inside the table.

Screenshot from Flamerobin when table is displayed

Am I looking in the wrong place or did I not understand the purpose / use of the Firebird monitoring tables?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

There are a number of things you need to know when using the monitoring tables:

  1. The monitoring tables (like MON$STATEMENTS) provides you a list of the active or prepared statements at the time a query was run.
  2. The query result stays stable until the transaction is committed! This means that repeatedly executing the query without committing will not yield new information.
  3. Only SYSDBA, the databaseowner or a user with role RDB$ADMIN can see all information, other users can only see information about their own connections.
  4. Your Firebird installation contains basic documentation on the tables in doc/README.monitoring_tables.txt

Now as to your screenshot: all statements are from the same connection (your own): MON$ATTACHMENT_ID = 1521. Only one statement is currently active (MON$STATE = 1) and participating in transaction MON$TRANSACTION_ID = 90964 and was started at 2012-12-06 10:08 (MON$TIMESTAMP), the rest is inactive (MON$STATE = 0) and therefor has no transaction-id and timestamp. The first statement is also the only one that currently has an actual query (MON$SQL_TEXT), which is the query that actual produced the result in the screenshot. In Firebird statements are allocated separately from the actual query to be executed using that statement.

That is not much, but if you had joined to MON$RECORD_STATS, MON$IO_STATS or MON$MEMORY_USAGE based on MON$STAT_ID you would have received statistics on the query (ie the number of reads, records update, number of pages read or written, memory use). The monitoring tables show information at a specific moment in time, and if a query has already finished when you execute it, you don't get any info (I am not 100%, but it might remain available until the next execute of a statement, or until the statement is unprepared or closed).

If instead you need a stream of information and statistics, than you might get more out of the Firebird Trace API. I haven't used it much myself yet, but the article Audit and Trace Services in Firebird 2.5 by Thomas Steinmauer provides a good introduction to it.

In your question you say you expected 'more content', but didn't actually specify what content you need or expected; I hope this provides sufficient info.

share|improve this answer
Thanks for your answer, it got me closer to understanding this tables. –  Valentin Despa Mar 7 '13 at 14:00
Thank you for your answer, I have another problem related to this one: How could Monitoring tables be updated? I run a query, but If I take a Look on ´MON$Statement´ I cant see the query I have runt it –  Kaja Jul 6 at 12:07
@Kaja See point 2: you need to commit the transaction used to query the monitoring tables to get new information. I hope my post also makes clear that MON$STATEMENTS doesn't contain historic information: it only contains information about statements being executed (or fetched from) at the time you queried the table (first time in a transaction). Otherwise I suggest you post another question. –  Mark Rotteveel Jul 6 at 12:56
Thanks alot for your answer. I have also commited my query, but as you said I am seeing only the last query, which I have run: ´select * from MON$STATEMENTS. I have written a new post Here –  Kaja Jul 6 at 13:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.