I am trying to add a simple index with the following SQL in Postgres, but the command keeps timing out:
CREATE INDEX playlist_tracklinks_playlist_enid ON playlist_tracklinks (playlist_enid);
The table definition is as follows:
=> \d playlist_tracklinks
Table "public.playlist_tracklinks"
Column | Type | Modifiers
----------------+---------------+--------------------
playlist_enid | numeric(20,0) | not null default 0
tracklink_enid | numeric(20,0) | not null default 0
position | integer | not null default 1
There are around 2.2 billion rows in the table, and it fails with the following error:
ERROR: canceling statement due to user request
I tried increasing the query timeout time with the following:
SET statement_timeout TO 360000000;
However it still hits that threshold. I have tried with and without CONCURRENTLY, and am sort of at a loss for what to do. Any suggestions would be greatly appreciated.
statement_timeout, but by a user cancel request. What interface do you use to access PostgreSQL? Try setting thes_tvalue to0, which turns this off.statement_timeoutset at0maintenance_work_memto the higher value you can, this will improve the index creating.