> Why are you messing with ctid? Does the table have no key? If not, you should fix that first.>
I got the idea from here
http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks