User check

From: Ben Clewett <B(dot)Clewett(at)roadrunner(dot)uk(dot)com>
To:
Cc: pgsql-novice(at)postgresql(dot)org
Subject: User check
Date: 2003-03-20 13:12:44
Message-ID: 3E79BE4C.5000000@roadrunner.uk.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

PostgreSQL,

I want to definitively check whether a user is logged in. I see there
is a table pg_stat_activity:

ben=# SELECT DISTINCT datname FROM ps_stat_activity

Are these better ways, or is this about right?

If right, does this table ever become corrupt, eg a TCP connection
failure without termination?

Whilst I am writing, something which has been bothering me. Does any
person know the quickest method for checking the existence of a record,
selected by Primary Key?

ben=# SELECT pk FROM table WHERE pk = value

I guess this way might be performance impared as it has to create the
output table with the extracted value.

ben=# SELECT COUNT(*) FROM table WHERE pk = value

I guess this might be faster, since it's only counting results without
creating a table. Or it might be slower if the table has already been
created, and then counted...

Ever a Novice, Ben.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message smauroz 2003-03-20 14:14:22 problem with function
Previous Message Duncan Adams (DNS) 2003-03-20 06:26:46 Re: Problems with copy