I have a rather large table (tens of millions of rows) and the app's startup script is running a few things, including the line:
CREATE INDEX IF NOT EXISTS idx_trades_ticker_ts ON exchange.trades (ticker, ts);
The index already exists, so I'd expect this to be a no-op, but it takes so long the connection times out.
The db then has this in the logs:
STATEMENT: -- create index
CREATE INDEX IF NOT EXISTS idx_trades_ticker_ts ON exchange.trades(ticker, ts)
ERROR: canceling statement due to user request
What could be the reason?
Edit:
- The cancelling due to user request is the client timing out and dropping the connection.
- The index does exist in the db
- Timeouts are all 30s
The issue happens both in the app's code and if I run the same query from DataGrip.
CREATE INDEXportion? Are you sure thatidx_trades_ticker_tsdoes exist? Do you havepostgresql.conf*_timeout(s) set? Add answers as update to question.