On 08/11/2021 17:10, Mark Rotteveel wrote: >> Also, if DSQL requests have stable ID, it's weird that more than one >> called routines would be linked to it (even if not at the same time) >> through MON$CALL_STACK (where request IDs are more correctly used). > > I'm confused about the case, or maybe I don't understand the problem you > have. As far as I understand, the statement id in MON$STATEMENTS > represents the statement handle.
Yes, at least apparently - only for DSQL. As DSQL statements handle always have a single request (it can't be concurrently called, now they can be called by others statements). But it's the request ID. An internal statement may have many requests. And that happens for functions and procedures, also present in MON$STATEMENTS. When a function is recursively called many requests are created (and many different records appear in MON$STATEMENTS. > So, if a statement handle has a > statement prepared, it should be the same for each execution of that > statement handle. If the statement handle is unprepared, it should still > have the same idea, same when it gets a new statement text. > The idea is to have MON$STATEMENTS representing requests and MON$COMPILED_STATEMENT representing internal (and future shareable part of a) statement. This shareable part already exist for PSQL statements. And I think memory usage for this part is not present in MON$ per statements currently. It goes only to the attachment or database stats. Adriano Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel