我正在尝试在大表上创建索引:
datid | datname | pid | usesysid | usename | application_name | client_addr | client_hostname | client_port | backend_start | xact_start | query_start | state_change | waiting | state | backend_xid | backend_xmin | query
-------+----------------------+-------+----------+-------------------------+--- --------------------------+--------------+-----------------+-------------+------ -------------------------+-------------------------------+---------------------- ---------+-------------------------------+---------+--------+-------------+----- ---------+---------------------------------------------------------------------- ---------------------
25439 | messengerdb | 30692 | 25438 | messengerdb_rw | pgAdmin III - Przegl??darka | 10.167.12.52 | | 50593 | 2016-08-11 05:27:12.101452+02 | 2016-08-11 05:28:01.535943+02 | 2016-08-11 05:28:01.535943+02 | 2016-08-11 05:28:01.535958+02 | t | active | | 1173740991 | CREATE INDEX CONCURRENTLY user_time_idx +
| | | | | | | | | | | | | | | | | ON core.conversations (user_id ASC NULLS LAST, last_message_timestamp ASC NULLS LAST);+此查询是否有效?我担心' waiting‘栏=== 't’这是否意味着它正在等待锁定或其他东西?
发布于 2016-08-11 15:21:19
并发创建索引可能需要很长时间,因为它不会锁定表的写入,它会等待其他事务完成。但是,如果您的连接在事务中处于空闲状态(例如,当客户端或应用程序在没有回滚/提交的情况下保持打开的连接时),它可能会永远等待。
检查事务中是否有空闲连接(您应该可以在进程列表中看到它们)。您还可以检查PostgreSQL日志。
PostgreSQL文档中的Section about creating index concurrently可能会有所帮助。还有一篇关于这个link下并发索引的很好的文章。
https://stackoverflow.com/questions/38889476
复制相似问题