Pgpool-II 4.0 adds new logging feature called "log_client_messages". This allows to log messages coming from frontend. Up to 3.7 the only way to log frontend messages was enable debugging log, which produced tremendous amount of logs.
For example, with log_client_messages enabled, "pgbench -S -M parepared -t 2" produces frontend logs below:
2018-12-04 16:43:45: pid 6522: LOG: Parse message from frontend.
2018-12-04 16:43:45: pid 6522: DETAIL: statement: "P0_1", query: "SELECT abalance FROM pgbench_accounts WHERE aid = $1;"
2018-12-04 16:43:45: pid 6522: LOG: Sync message from frontend.
2018-12-04 16:43:45: pid 6522: LOG: Bind message from frontend.
2018-12-04 16:43:45: pid 6522: DETAIL: portal: "", statement: "P0_1"
2018-12-04 16:43:45: pid 6522: LOG: Describe message from frontend.
2018-12-04 16:43:45: pid 6522: DETAIL: portal: ""
2018-12-04 16:43:45: pid 6522: LOG: Execute message from frontend.
2018-12-04 16:43:45: pid 6522: DETAIL: portal: ""
2018-12-04 16:43:45: pid 6522: LOG: Sync message from frontend.
As you can see, pgbench sends a query "SELECT abalance FROM pgbench_accounts WHERE aid = $1;" using prepared statement "P0_1", then bind message to bind parameter to be bound to "$1".
It then sends describe message to obtain meta data, and finally sends execute message to run the query.
Below are the second execution of query (remember that we add "-t 2" parameter to execute 2 transactions).
2018-12-04 16:43:45: pid 6522: LOG: Bind message from frontend.
2018-12-04 16:43:45: pid 6522: DETAIL: portal: "", statement: "P0_1"
2018-12-04 16:43:45: pid 6522: LOG: Describe message from frontend.
2018-12-04 16:43:45: pid 6522: DETAIL: portal: ""
2018-12-04 16:43:45: pid 6522: LOG: Execute message from frontend.
2018-12-04 16:43:45: pid 6522: DETAIL: portal: ""
2018-12-04 16:43:45: pid 6522: LOG: Sync message from frontend.
2018-12-04 16:43:45: pid 6522: LOG: Terminate message from frontend.
This time no parse message is sent because pgbench reuses the named statement "P0_1", which eliminates the parse/analythis step. So pgbench runs in the mode very fast comparing with other mode.
In summary log_client_messages is useful when you want to extract very detail info regarding what the client is doing.
Tuesday, December 4, 2018
Subscribe to:
Posts (Atom)
Row pattern recognition feature for PostgreSQL
What is row pattern recognition feature? Row pattern recognition (RPR) is a feature defined in the SQL standard. It allows to search for a s...
-
What is row pattern recognition feature? Row pattern recognition (RPR) is a feature defined in the SQL standard. It allows to search for a s...
-
There are several timeout parameters in Pgpool-II. In this blog I will explain those parameters used for connection management. Below is...