You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/sql.extensions/README.profiler.md
+32-11Lines changed: 32 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,13 @@ This documentation treats the engine and plugin parts as a single thing, in the
8
8
9
9
The `RDB$PROFILER` package allows to profile execution of PSQL code collecting statistics of how many times each line was executed along with its minimum, maximum and accumulated execution times (with nanoseconds precision), as well open and fetch statistics of implicit and explicit SQL cursors.
10
10
11
-
To collect profile data, an user must first start a profile session with `RDB$PROFILER.START_SESSION`. This function returns an profile session ID which is later stored in the profiler snapshot tables to be queried and analyzed by the user.
11
+
To collect profile data, an user must first start a profile session with `RDB$PROFILER.START_SESSION`. This function returns an profile session ID which is later stored in the profiler snapshot tables to be queried and analyzed by the user. A profiler session may be local (same attachment) or remote (another attachment).
12
12
13
-
After a session is started, PSQL and SQL statements statistics starts to be collected in memory. Note that a profile session collects data only of statements executed in the same attachment where the session was started.
13
+
Remote profiling just forwards commands to the remote attachment. So it's possible that a client simultaneous profile multiple attachments. It's also possible that a locally or remotely started profile session have commands issued by another attachment.
14
+
15
+
Remote issued commands needs that the target attachment be in an idle state, i.e., not executing others requests. When they are not idle the call blocks waiting for that state.
16
+
17
+
After a session is started, PSQL and SQL statements statistics starts to be collected in memory. Note that a profile session collects data only of statements executed in the same attachment associated with the session.
14
18
15
19
Data is aggregated and stored per requests (i.e. a statement execution). When querying snapshot tables, user may do extra aggregation per statements or use the auxiliary views that do that automatically.
16
20
@@ -120,67 +124,84 @@ select pstat.*
120
124
121
125
## Function `START_SESSION`
122
126
123
-
`RDB$PROFILER.START_SESSION` starts a new profiler session, turns it the current session and return its identifier.
127
+
`RDB$PROFILER.START_SESSION` starts a new profiler session, turns it the current session (of the given `ATTACHMENT_ID`) and return its identifier.
124
128
125
129
If `PLUGIN_NAME` is `NULL` (the default) it uses the database configuration `DefaultProfilerPlugin`.
126
130
127
131
`PLUGIN_OPTIONS` is plugin specific options and currently should be `NULL` for `Default_Profiler` plugin.
128
132
129
133
Input parameters:
130
134
-`DESCRIPTION` type `VARCHAR(255) CHARACTER SET UTF8` default `NULL`
135
+
-`ATTACHMENT_ID` type `BIGINT NOT NULL` default `CURRENT_CONNECTION`
131
136
-`PLUGIN_NAME` type `VARCHAR(255) CHARACTER SET UTF8` default `NULL`
132
137
-`PLUGIN_OPTIONS` type `VARCHAR(255) CHARACTER SET UTF8` default `NULL`
133
138
134
139
Return type: `BIGINT NOT NULL`.
135
140
136
141
## Procedure `PAUSE_SESSION`
137
142
138
-
`RDB$PROFILER.PAUSE_SESSION` pauses the current profiler session so the next executed statements statistics are not collected.
143
+
`RDB$PROFILER.PAUSE_SESSION` pauses the current profiler session (of the given `ATTACHMENT_ID`) so the next executed statements statistics are not collected.
139
144
140
145
If `FLUSH` is `TRUE` the snapshot tables are updated with data up to the current moment. Otherwise data remains only in memory for later update.
141
146
142
-
Calling `RDB$PROFILER.PAUSE_SESSION(TRUE)` has the same semantics of calling `RDB$PROFILER.PAUSE_SESSION(FALSE)` followed by `RDB$PROFILER.FLUSH`.
147
+
Calling `RDB$PROFILER.PAUSE_SESSION(TRUE)` has the same semantics of calling `RDB$PROFILER.PAUSE_SESSION(FALSE)` followed by `RDB$PROFILER.FLUSH` (using the same `ATTACHMENT_ID`).
143
148
144
149
Input parameters:
145
150
-`FLUSH` type `BOOLEAN NOT NULL` default `FALSE`
151
+
-`ATTACHMENT_ID` type `BIGINT NOT NULL` default `CURRENT_CONNECTION`
146
152
147
153
## Procedure `RESUME_SESSION`
148
154
149
-
`RDB$PROFILER.RESUME_SESSION` resumes the current profiler session if it was paused so the next executed statements statistics are collected again.
155
+
`RDB$PROFILER.RESUME_SESSION` resumes the current profiler session (of the given `ATTACHMENT_ID`) if it was paused so the next executed statements statistics are collected again.
156
+
157
+
Input parameters:
158
+
-`ATTACHMENT_ID` type `BIGINT NOT NULL` default `CURRENT_CONNECTION`
150
159
151
160
## Procedure `FINISH_SESSION`
152
161
153
-
`RDB$PROFILER.FINISH_SESSION` finishes the current profiler session.
162
+
`RDB$PROFILER.FINISH_SESSION` finishes the current profiler session (of the given `ATTACHMENT_ID`).
154
163
155
164
If `FLUSH` is `TRUE` the snapshot tables are updated with data of the finished session (and old finished sessions not yet present in the snapshot). Otherwise data remains only in memory for later update.
156
165
157
-
Calling `RDB$PROFILER.FINISH_SESSION(TRUE)` has the same semantics of calling `RDB$PROFILER.FINISH_SESSION(FALSE)` followed by `RDB$PROFILER.FLUSH`.
166
+
Calling `RDB$PROFILER.FINISH_SESSION(TRUE)` has the same semantics of calling `RDB$PROFILER.FINISH_SESSION(FALSE)` followed by `RDB$PROFILER.FLUSH` (using the same `ATTACHMENT_ID`).
158
167
159
168
Input parameters:
160
169
-`FLUSH` type `BOOLEAN NOT NULL` default `TRUE`
170
+
-`ATTACHMENT_ID` type `BIGINT NOT NULL` default `CURRENT_CONNECTION`
161
171
162
172
## Procedure `CANCEL_SESSION`
163
173
164
-
`RDB$PROFILER.CANCEL_SESSION` cancels the current profiler session.
174
+
`RDB$PROFILER.CANCEL_SESSION` cancels the current profiler session (of the given `ATTACHMENT_ID`).
165
175
166
176
All session data present in the profiler plugin is discarded and will not be flushed.
167
177
168
178
Data already flushed is not deleted automatically.
169
179
180
+
Input parameters:
181
+
-`ATTACHMENT_ID` type `BIGINT NOT NULL` default `CURRENT_CONNECTION`
182
+
170
183
## Procedure `DISCARD`
171
184
172
-
`RDB$PROFILER.DISCARD` removes all sessions from memory, without flushing them.
185
+
`RDB$PROFILER.DISCARD` removes all sessions (of the given `ATTACHMENT_ID`) from memory, without flushing them.
173
186
174
187
If there is a active session, it is cancelled.
175
188
189
+
Input parameters:
190
+
-`ATTACHMENT_ID` type `BIGINT NOT NULL` default `CURRENT_CONNECTION`
191
+
176
192
## Procedure `FLUSH`
177
193
178
-
`RDB$PROFILER.FLUSH` updates the snapshot tables with data from the profile sessions in memory.
194
+
`RDB$PROFILER.FLUSH` updates the snapshot tables with data from the profile sessions (of the given `ATTACHMENT_ID`) in memory.
179
195
180
196
After update data is stored in tables `PLG$PROF_SESSIONS`, `PLG$PROF_STATEMENTS`, `PLG$PROF_RECORD_SOURCES`, `PLG$PROF_REQUESTS`, `PLG$PROF_PSQL_STATS` and `PLG$PROF_RECORD_SOURCE_STATS` and may be read and analyzed by the user.
181
197
182
198
It also removes finished sessions from memory.
183
199
200
+
If a remote `ATTACHMENT_ID` is used the data is updated in an autonomous transaction.
201
+
202
+
Input parameters:
203
+
-`ATTACHMENT_ID` type `BIGINT NOT NULL` default `CURRENT_CONNECTION`
204
+
184
205
# Snapshot tables
185
206
186
207
Snapshot tables (as well views and sequence) are automatically created in the first usage of the profiler. They are owned by the current user with read/write permissions for `PUBLIC`.
0 commit comments