答复: [ADMIN] blocking issue when create index concurrently

From: xu jian <jamesxu(at)outlook(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: 答复: [ADMIN] blocking issue when create index concurrently
Date: 2016-12-15 18:39:14
Message-ID: MWHPR20MB1421BF01C05147053F6F64CAA19D0@MWHPR20MB1421.namprd20.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thanks Tom for your reply. the reason we want to run create index on different table concurrently is , we find the create index is single thread, rebuild index one by one tasks long time,

and our storage io has enough bandwidth , so cpu is bottleneck is this case. we don't want to hit the server hardly, however, running 2 recreate index concurrently on different table is still manageable for our system.

for your mention "CREATE INDEX CONCURRENTLY where it has to wait for all other transactions to exit", does it mean if there is user open translation, recreate index concurrently will be blocked? no matter which table the transaction is on ? thanks

James

________________________________
发件人: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
发送时间: 2016年12月15日 12:33:37
收件人: xu jian
抄送: pgsql-admin(at)postgresql(dot)org
主题: Re: [ADMIN] blocking issue when create index concurrently

xu jian <jamesxu(at)outlook(dot)com> writes:
> I was trying to create 2 indexes concurrently(on different table) in same database. I didn't expect the first create index operation would block the other one since they were running on different table.

> However, it is not true. I found one creating index command was blocking the other one.

There are (IIRC) two separate points in CREATE INDEX CONCURRENTLY where it
has to wait for all other transactions to exit. That would include a
transaction running another CREATE INDEX (CONCURRENTLY), even if it's for
a different table. I think running two at once would end in a deadlock
failure, since they would likely end up waiting for each other.

Usually, if you're using C.I.C., you're trying to minimize the impact
on the rest of the system, so running two at once seems a bit
counterproductive anyway.

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Campbell, Lance 2016-12-16 15:30:14 unique constraints
Previous Message Tom Lane 2016-12-15 17:33:37 Re: blocking issue when create index concurrently