Thread: count (*)

count (*)

From
alonso
Date:
What would cause psql to hang indefinitely when the backend disappears?

We have a script that uses psql to insert a record (TCP connection to DB
on different machine). The command is basically
psql <connection_stuff> -c "insert into..."

A while back I had to restart the server and today discovered that some
of the client machines have psql processes dating back several months.

Obviously no TCP connection on the server end but client-side shows the
connection as "ESTABLISHED".
--
View this message in context: http://www.nabble.com/database-still-hanging-tf4440057.html#a12668226
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


Re: count (*)

From
"Albe Laurenz"
Date:
alonso wrote:
> I've got it, but I don't know the reason of it.
> In the database table the records have duplicated and I've
> two rows for
> every primary key - with different OIDs.
> Very strange however...

Very strange indeed.

Are you positive that there is a primary key constraint on
the column? Can you show some evidence?

> Is there any safe method to get rid of only one of each
> duplicated row?

If "id" is your "primary key":

DELETE FROM test USING test a
WHERE test.id = a.id AND test.oid > a.oid;

Yours,
Laurenz Albe