Home > postgresql > Postgres “Select * from ” freezes

Postgres “Select * from ” freezes

Problem:
Due to a programming error in a python program I had written, I was unknowingly preventing postgres from obtaining an access lock to a table. There were no errors but trying to run a

Select * from <table>

would just freeze.

Solution:
The solution was to fix the python program. But I used the following query to get some more insight into what was causing the issue.

$ psql -U myuser -h localhost mydatabase
Password for user myuser: 
psql (10.8 (Ubuntu 10.8-1.pgdg14.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

mydatabase=> SELECT *                                  
  FROM pg_locks l
  JOIN pg_class t ON l.relation = t.oid AND t.relkind = 'r'
 WHERE t.relname = '<table>';
 pid  
------
 2028
 2159
 2029
 2357
 2106
 2409
 2128
 2387
 2084
(9 rows)

mydatabase=> \q


Source:

https://stackoverflow.com/questions/10317114/postgresql-drop-table-doesnt-work

Categories: postgresql
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: