2

We've turned on some slow query logging on a postgres 9.1 cluster and see the following in the logs::

2016-08-08 13:05:51 AEST LOG:  duration: 24126.105 ms  execute fetch from S_26/C_775: SELECT ...(query continues)

What does the S_26/C_775 bit mean? Can I use this to find which client submitted the query?

1 Answer 1

3

S_26 is a statement name and C_775 a portal name in the extended-query protocol.

See https://www.postgresql.org/docs/current/static/protocol-overview.html

In the extended-query protocol, execution of SQL commands is divided into multiple steps. The state retained between steps is represented by two types of objects: prepared statements and portals. A prepared statement represents the result of parsing and semantic analysis of a textual query string. A prepared statement is not in itself ready to execute, because it might lack specific values for parameters. A portal represents a ready-to-execute or already-partially-executed statement, with any missing parameter values filled in. (For SELECT statements, a portal is equivalent to an open cursor, but we choose to use a different term since cursors don't handle non-SELECT statements.)

To find the query bound to this statement, look upper in the log for the corresponding bind entry.

If it doesn't exist, you might have to increase the logging level to DEBUG2 through log_min_error_statement, or set log_min_duration_statement to 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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