Andrew Dunstan <[EMAIL PROTECTED]> writes:
> Rodrigo De Leon wrote:
>> You could do this:
>>
>> SELECT procpid||' '||backend_start
>> FROM pg_stat_activity
>> WHERE datname = current_database()
>> AND usename = session_user
>> AND client_addr = inet_client_addr()
>> AND client_port = inet_client_port();
> That's pretty roundabout.
Indeed. Use pg_backend_pid() instead:
SELECT whatever FROM pg_stat_activity WHERE procpid = pg_backend_pid();
A difficulty with this in existing releases is that pg_stat_activity
lags behind reality, so that you won't see your session listed in it
until you've been connected at least half a second or so. 8.2 won't
have that problem.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match