Skip to content

Add pg_stat_session #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add pg_stat_session #8

wants to merge 1 commit into from

Conversation

sdudoladov
Copy link
Owner

catversion bump because of the change in the contents of pg_stat_activity

Author: Sergey Dudoladov

Reviewed-by:

Discussion:
https://www.postgresql.org/message-id/flat/CA%2BFpmFcJF0vwi-SWW0wYO-c-FbhyawLq4tCpRDCJJ8Bq%3Dja-gA%40mail.gmail.com

succeeds an older patch done at #5

@sdudoladov sdudoladov force-pushed the add-pg-stat-session branch 2 times, most recently from a56bc66 to 52acfe4 Compare December 27, 2022 08:22
@hughcapet
Copy link

Don't you think that the task of differentiating "5 hours of idle-in-transaction time in a single block and the same 5 hours accumulated across 300 mini-idles" can be done by just calculating the total_transaction_idle_time/total_active_time value. I have some doubts about those proposed counters.

typedef struct PgBackendSessionStatus
{
/* Counters accumulated since the start of the session */
int64 total_active_time;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PgStat_Counter instead of int64?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vaguely recall we discussed in an earleir version we go with int64.
I will leave that comment unresolved for now to return to it later

@sdudoladov
Copy link
Owner Author

Don't you think that the task of differentiating "5 hours of idle-in-transaction time in a single block and the same 5 hours accumulated across 300 mini-idles" can be done by just calculating the total_transaction_idle_time/total_active_time value. I have some doubts about those proposed counters.

To be fair, counters are the solution requested on the mailing list.
I've thought for a while about your suggestion and I think I will post it to the mailing list for discussion.

@sdudoladov sdudoladov force-pushed the add-pg-stat-session branch 2 times, most recently from 122612a to 9e2db1c Compare January 12, 2023 20:03
@@ -618,6 +643,21 @@ pgstat_report_activity(BackendState state, const char *cmd_str)
beentry->st_activity_start_timestamp = start_timestamp;
}

beentry->st_session.total_running_time += st_session_diff.total_running_time;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I welcome any suggestions on improving this part.

@sdudoladov
Copy link
Owner Author

@hughcapet can you double-check the values reported by *count fields are sane ?

Author: Sergey Dudoladov

Adds pg_stat_session view to track statistics accumulated during
 lifetime of a session (client backend).

catversion bump is necessary due to a new view / function

Reviewed-by: Aleksander Alekseev, Bertrand Drouvot, and Atsushi
Torikoshi

Discussion:
https://www.postgresql.org/message-id/flat/CA%2BFpmFcJF0vwi-SWW0wYO-c-FbhyawLq4tCpRDCJJ8Bq%3Dja-gA%40mail.gmail.com
@sdudoladov sdudoladov force-pushed the add-pg-stat-session branch from 31f781e to 2a4a7c1 Compare June 12, 2023 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants