note 119642 added to function.pg-connect

From: Date: Sat, 23 Jul 2016 21:37:33 +0000
Subject: note 119642 added to function.pg-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-206088@lists.php.net to get a copy of this message
It is worth to know, that you can set application_name in connection string, consider this simple example: <?php $appName = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $connStr = "host=localhost port=5432 dbname=postgres user=postgres options='--application_name=$appName'"; //simple check $conn = pg_connect($connStr); $result = pg_query($conn, "select * from pg_stat_activity"); var_dump(pg_fetch_all($result)); ?> By doing this move on cli or cgi you can see in pgAdmin what scripts are running or what requests are running on database. You can extend configuration of postgres to track slow queries and print application name to logs. It was very usuful to me to find out what and where should I optimize. ---- Server IP: 72.52.91.14 Probable Submitter: 85.89.184.132 ---- Manual Page -- http://php.net/manual/en/function.pg-connect.php Edit -- https://master.php.net/note/edit/119642 Del: integrated -- https://master.php.net/note/delete/119642/integrated Del: useless -- https://master.php.net/note/delete/119642/useless Del: bad code -- https://master.php.net/note/delete/119642/bad+code Del: spam -- https://master.php.net/note/delete/119642/spam Del: non-english -- https://master.php.net/note/delete/119642/non-english Del: in docs -- https://master.php.net/note/delete/119642/in+docs Del: other reasons-- https://master.php.net/note/delete/119642 Reject -- https://master.php.net/note/reject/119642 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206088) next »