检索PostgreSQL中索引创建过程的进度

And*_*niy 5 postgresql

考虑长期运行PostgreSQL的索引创建查询,像这样:

CREATE INDEX some_idx   
   ON some_table   USING btree  
      (some_varchar_column COLLATE pg_catalog."default");
Run Code Online (Sandbox Code Playgroud)

问题是:如何检索此查询过程的进度?有可能吗?

知道两种情况下的方式很有趣:

  1. 运用 pgAdmin
  2. 运用 SQL
  3. 使用一些内部postgreSQL工具.

可能这个额外的信息可能会影响答案:PostgreSQL 9.3on Windows 7 64 bit.

Rob*_*kan 5

在 Postgres v12+ 中,视图pg_stat_progress_create_index应该为您提供此信息。

https://www.postgresql.org/docs/12/progress-reporting.html


hd1*_*hd1 3

有一个关于这个主题的wiki 页面,其中链接到多个链接。早在几年前,它们的准确性就受到质疑。还有一个2006 年或 2007 年关于添加进度指示器的黑客主题,其中 EnterpriseDB 的 Greg Stark 也提出了同样的观点。