[TNM] Obtaining SQL statement that caused required sort in temp file

Greg Sabino Mullane greg at endpoint.com
Thu Nov 24 01:05:34 UTC 2011


> Would someone be so good as to briefly explain to me how the script is
> obtaining the SQL statement for each temporary file created?

Queries are generally grouped by PID, if that is available, so that's 
the primary way it does what it does. In the case of tempfiles, 
the logs will look something like this:

2011-11-23 20:03:05 EST greg at greg [9504] LOG:  temporary file: path "base/pgsql_tmp/pgsql_tmp9504.2", size 44702
2011-11-23 20:03:05 EST greg at greg [9504] STATEMENT:  SELECT name FROM  (SELECT pg_catalog.lower(name) AS name FROM pg_catalog.pg_settings   WHERE context IN ('user', 'superuser')   UNION ALL SELECT 'constraints'   UNION ALL SELECT 'transaction'   UNION ALL SELECT 'session'   UNION ALL SELECT 'role'   UNION ALL SELECT 'tablespace'   UNION ALL SELECT 'all') ss  WHERE substring(name,1,4)='work'

tail_n_mail gathers together the whole things as one string, replaces the 
'LOG: temporary file:' line with a cleaner output, and then spits out the rest 
of the log for that PID (which is the executing statement).

-- 
Greg Sabino Mullane greg at endpoint.com
End Point Corporation
PGP Key: 0x14964AC8
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
Url : https://mail.endcrypt.com/pipermail/tnm/attachments/20111123/ef87ee37/attachment.bin 


More information about the TNM mailing list