I'm trying to add a new column
ALTER TABLE "Cidade" ADD COLUMN "BoundBox" VARCHAR(255)
to this table:
 "Cidade"
    "Id" integer not null
        constraint "Cidade_PK"
            primary key,
    "Nome" varchar(120),
    "EstadoId" integer not null
        constraint "Estado_Cidade_FK"
            references "Estado",
    "PontoCentralLatitude" numeric,
    "PontoCentralLongitude" numeric
But the query never finish, I've already waited for 5 minutes and nothing happened. The table has only 5,000 records, and I can't wait too much time since it block the access to the table. I have a test database (equal to production), and it worked very quickly. The postgres version is 9.5.6.
If you are running PostgreSQL 9.6+ you can use pg_blocking_pids() to find PID of queries that lock your one.
select pid, pg_blocking_pids(pid) as blocked_by, query as blocked_query
from pg_stat_activity
where pg_blocking_pids(pid)::text != '{}';
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With