sqlpostgresqlcreate-table

Create Table Postgres in new schema does not complete


When trying to run a simple create statement in a new schema within postgres (healthcare), the query never finishes. My question is why?

CREATE TABLE healthcare.admission_source(
    admission_source_id INTEGER, 
    admission_source INTEGER,
    description varchar(255)
);

Verified the schema exists with ownership & rights:

enter image description here

I have ran this same query before, and it runs endlessly. I canceled it at several hours last time, but wanted to show it takes a long time to run a CREATE TABLE statement:

enter image description here


For comparison, the query runs for 42 msec on the public schema of this database. The table is created correctly and the query finishes quickly, so leaves me thinking that the healthcare schema is the issue. Would love all thoughts and assistance enter image description here


Solution

  • It is probably blocking on a lock. If you have log_lock_waits turned on, you can look in the log file to see what is going on.

    This could happen for example of another session tried to create a table of the same name inside a transaction and didn't commit the transaction.