Re: 回复:how to create index concurrently on partitioned table

2020-10-05 Thread Michael Paquier
On Mon, Oct 05, 2020 at 10:07:33PM -0500, Justin Pryzby wrote: > Honestly, I think you're over-thinking and over-engineering indisclustered. > > If "clusteredness" was something we offered to maintain across DML, I think > that might be important to provide stronger guarantees. As it is now, I

Re: 回复:how to create index concurrently on partitioned table

2020-10-05 Thread Justin Pryzby
On Tue, Oct 06, 2020 at 11:42:55AM +0900, Michael Paquier wrote: > On Mon, Oct 05, 2020 at 03:08:32PM -0500, Justin Pryzby wrote: > > It means that we might do N catalog updates for a partition heirarchy > > that's N > > levels deep. Normally, N=2, and we'd clear indisclustered for the index as

Re: 回复:how to create index concurrently on partitioned table

2020-10-05 Thread Justin Pryzby
On Mon, Oct 05, 2020 at 05:46:27PM +0900, Michael Paquier wrote: > On Sat, Sep 26, 2020 at 02:56:55PM -0500, Justin Pryzby wrote: > > Also, if a partitioned index is clustered, when we clear indisclustered for > > other indexes, should we also propogate that to their parent indexes, if > > any ?

Re: 回复:how to create index concurrently on partitioned table

2020-10-05 Thread Michael Paquier
On Sat, Sep 26, 2020 at 02:56:55PM -0500, Justin Pryzby wrote: > Also, if a partitioned index is clustered, when we clear indisclustered for > other indexes, should we also propogate that to their parent indexes, if any ? I am not sure what you mean here. Each partition's cluster runs in its own

Re: 回复:how to create index concurrently on partitioned table

2020-09-26 Thread Justin Pryzby
On Thu, Sep 24, 2020 at 05:11:03PM +0900, Michael Paquier wrote: > start. So, the goal of the patch, as I would define it, is to give a > way to CLUSTER to work on a partitioned table using a given > partitioned index. Hence, we would perform CLUSTER automatically from > the top-most parent for

Re: 回复:how to create index concurrently on partitioned table

2020-09-24 Thread Michael Paquier
On Mon, Sep 14, 2020 at 09:31:03AM -0500, Justin Pryzby wrote: > Anyway, for now this is rebased on 83158f74d. I have not thought yet about all the details of CIC and DIC and what you said upthread, but I have gone through CLUSTER for now, as a start. So, the goal of the patch, as I would define

Re: 回复:how to create index concurrently on partitioned table

2020-09-14 Thread Justin Pryzby
On Sat, Sep 12, 2020 at 10:35:34AM +0900, Michael Paquier wrote: > On Fri, Sep 11, 2020 at 07:13:01PM -0500, Justin Pryzby wrote: > > On Tue, Sep 08, 2020 at 01:31:05PM +0900, Michael Paquier wrote: > >> - CIC on partitioned relations. (Should we also care about DROP INDEX > >> CONCURRENTLY as

Re: 回复:how to create index concurrently on partitioned table

2020-09-11 Thread Michael Paquier
On Fri, Sep 11, 2020 at 07:13:01PM -0500, Justin Pryzby wrote: > On Tue, Sep 08, 2020 at 01:31:05PM +0900, Michael Paquier wrote: >> - CIC on partitioned relations. (Should we also care about DROP INDEX >> CONCURRENTLY as well?) > > Do you have any idea what you think that should look like for

Re: 回复:how to create index concurrently on partitioned table

2020-09-11 Thread Justin Pryzby
On Tue, Sep 08, 2020 at 01:31:05PM +0900, Michael Paquier wrote: > - CIC on partitioned relations. (Should we also care about DROP INDEX > CONCURRENTLY as well?) Do you have any idea what you think that should look like for DROP INDEX CONCURRENTLY ? -- Justin

Re: 回复:how to create index concurrently on partitioned table

2020-09-07 Thread Michael Paquier
On Mon, Sep 07, 2020 at 09:39:16PM -0500, Justin Pryzby wrote: > Also, my previous revision failed to implement your suggestion to first build > catalog entries with INVALID indexes and to then reindex them. Fixed. - childStmt->oldCreateSubid = InvalidSubTransactionId; -

Re: 回复:how to create index concurrently on partitioned table

2020-09-07 Thread Justin Pryzby
Thanks for completing and pushing the REINDEX patch and others. Here's a rebasified + fixed version of the others. On Tue, Sep 01, 2020 at 02:51:58PM +0900, Michael Paquier wrote: > The REINDEX patch is progressing its way, so I have looked a bit at > the part for CIC. > > Visibly, the case of

Re: 回复:how to create index concurrently on partitioned table

2020-09-07 Thread Anastasia Lubennikova
On 07.09.2020 04:58, Michael Paquier wrote: On Fri, Sep 04, 2020 at 09:51:13AM +0900, Michael Paquier wrote: Glad to hear that, please take the time you need. Attached is a rebased version to address the various conflicts after 844c05a. -- Michael Thank you. With the fix for the cycle in

Re: 回复:how to create index concurrently on partitioned table

2020-09-06 Thread Michael Paquier
On Fri, Sep 04, 2020 at 09:51:13AM +0900, Michael Paquier wrote: > Glad to hear that, please take the time you need. Attached is a rebased version to address the various conflicts after 844c05a. -- Michael diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index

Re: 回复:how to create index concurrently on partitioned table

2020-09-03 Thread Michael Paquier
On Thu, Sep 03, 2020 at 10:02:58PM +0300, Anastasia Lubennikova wrote: > First of all, this patch fails at cfbot: > > indexcmds.c:2848:7: error: variable ‘parentoid’ set but not used > [-Werror=unused-but-set-variable] > Oid parentoid;^ Missed this warning, thanks for pointing it out. This is

Re: 回复:how to create index concurrently on partitioned table

2020-09-03 Thread Anastasia Lubennikova
On 02.09.2020 04:39, Michael Paquier wrote: The problem with dropped relations in REINDEX has been addressed by 1d65416, so I have gone through this patch again and simplified the use of session locks, these being taken only when doing a REINDEX CONCURRENTLY for a given partition. This part is

Re: 回复:how to create index concurrently on partitioned table

2020-09-01 Thread Michael Paquier
On Fri, Aug 14, 2020 at 09:29:45AM +0900, Michael Paquier wrote: > Once this gets done, we should then be able to get rid of the extra > session locking taken when building the list of partitions, limiting > session locks to only be taken during the concurrent reindex of a > single partition (the

Re: 回复:how to create index concurrently on partitioned table

2020-08-31 Thread Michael Paquier
On Sun, Aug 09, 2020 at 06:44:23PM -0500, Justin Pryzby wrote: > Thanks for looking. The REINDEX patch is progressing its way, so I have looked a bit at the part for CIC. Visibly, the case of multiple partition layers is not handled correctly. Here is a sequence that gets broken: CREATE TABLE

Re: 回复:how to create index concurrently on partitioned table

2020-08-13 Thread Michael Paquier
On Wed, Aug 12, 2020 at 10:37:08PM +0900, Michael Paquier wrote: > I have been able to work more on this patch today, and finally added > an error context for the transaction block check, as that's cleaner. > In my manual tests, I have also bumped into a case that failed with > the original patch

Re: 回复:how to create index concurrently on partitioned table

2020-08-12 Thread Michael Paquier
On Wed, Aug 12, 2020 at 12:28:20AM -0500, Justin Pryzby wrote: > On Wed, Aug 12, 2020 at 01:54:38PM +0900, Michael Paquier wrote: >> +++ b/src/backend/catalog/index.c >> @@ -3661,20 +3662,12 @@ reindex_relation(Oid relid, int flags, int options) >> +elog(ERROR, "unsupported relation

Re: 回复:how to create index concurrently on partitioned table

2020-08-11 Thread Justin Pryzby
Thanks for helping with this. On Wed, Aug 12, 2020 at 01:54:38PM +0900, Michael Paquier wrote: > +++ b/src/backend/catalog/index.c > @@ -3661,20 +3662,12 @@ reindex_relation(Oid relid, int flags, int options) > + elog(ERROR, "unsupported relation kind for relation \"%s\"", > +

Re: 回复:how to create index concurrently on partitioned table

2020-08-11 Thread Michael Paquier
On Sun, Aug 09, 2020 at 06:44:23PM -0500, Justin Pryzby wrote: > On Sun, Aug 09, 2020 at 02:00:09PM +0900, Michael Paquier wrote: >> For now, I would recommend to focus first on 0001 to add support for >> partitioned tables and indexes to REINDEX. CIC is much more >> complicated btw, but I am not

Re: 回复:how to create index concurrently on partitioned table

2020-08-09 Thread Justin Pryzby
Thanks for looking. On Sun, Aug 09, 2020 at 02:00:09PM +0900, Michael Paquier wrote: > > exactly what's needed. > > For now, I would recommend to focus first on 0001 to add support for > partitioned tables and indexes to REINDEX. CIC is much more > complicated btw, but I am not entering in the

Re: 回复:how to create index concurrently on partitioned table

2020-08-08 Thread Michael Paquier
On Sat, Aug 08, 2020 at 01:37:44AM -0500, Justin Pryzby wrote: > That gave me the idea to layer CIC on top of Reindex, since I think it does > exactly what's needed. For now, I would recommend to focus first on 0001 to add support for partitioned tables and indexes to REINDEX. CIC is much more

Re: 回复:how to create index concurrently on partitioned table

2020-08-08 Thread Justin Pryzby
On Mon, Jun 15, 2020 at 09:37:42PM +0900, Michael Paquier wrote: > On Mon, Jun 15, 2020 at 08:15:05PM +0800, 李杰(慎追) wrote: > > As shown above, an error occurred while creating an index in the second > > partition. > > It can be clearly seen that the index of the partitioned table is invalid > >

回复:回复:回复:回复:how to create index concurrently on partitioned table

2020-06-18 Thread 李杰(慎追)
u think that scheme is more suitable for CIC? Thank you very much, Regards, Adger -- 发件人:Michael Paquier 发送时间:2020年6月18日(星期四) 10:41 收件人:李杰(慎追) 抄 送:Justin Pryzby ; pgsql-hackers ; 曾文旌(义从) ; Alvaro Herrera 主 题:Re: 回复:回复

Re: 回复:回复:回复:how to create index concurrently on partitioned table

2020-06-17 Thread Michael Paquier
On Wed, Jun 17, 2020 at 10:22:28PM +0800, 李杰(慎追) wrote: > However, I found a problem. If there are many partitions, > we may need to handle too many missing index entries when > validate_index(). Especially for the first partition, the time may > have been long and many entries are missing. In

回复:回复:回复:how to create index concurrently on partitioned table

2020-06-17 Thread 李杰(慎追)
> We can refer to the implementation in the ReindexRelationConcurrently, > in the three phases of the REINDEX CONCURRENTLY, > all indexes of the partitions are operated one by one in each phase. > In this way, we can maintain the consistency of the entire partitioned table > index. > After we

回复:回复:回复:how to create index concurrently on partitioned table

2020-06-16 Thread 李杰(慎追)
ink is more helpful to realize CIC? -- 发件人:Michael Paquier 发送时间:2020年6月16日(星期二) 09:02 收件人:李杰(慎追) 抄 送:Justin Pryzby ; pgsql-hackers ; 曾文旌(义从) ; Alvaro Herrera 主 题:Re: 回复:回复:how to create index concurrently on partitioned table

Re: 回复:回复:how to create index concurrently on partitioned table

2020-06-15 Thread Michael Paquier
On Mon, Jun 15, 2020 at 09:33:05PM +0800, 李杰(慎追) wrote: > This is a good idea. > We should maintain the consistency of the entire partition table. > However, this is not a small change in the code. > May be we need to make a new design for DefineIndex function Indeed. I have looked at the

回复:回复:how to create index concurrently on partitioned table

2020-06-15 Thread 李杰(慎追)
rrera 主 题:Re: 回复:how to create index concurrently on partitioned table On Mon, Jun 15, 2020 at 08:15:05PM +0800, 李杰(慎追) wrote: > As shown above, an error occurred while creating an index in the second > partition. > It can be clearly seen that the index of the partitioned table is invalid

Re: 回复:how to create index concurrently on partitioned table

2020-06-15 Thread Michael Paquier
On Mon, Jun 15, 2020 at 08:15:05PM +0800, 李杰(慎追) wrote: > As shown above, an error occurred while creating an index in the second > partition. > It can be clearly seen that the index of the partitioned table is invalid > and the index of the first partition is normal, the second partition is >

回复:how to create index concurrently on partitioned table

2020-06-15 Thread 李杰(慎追)
, it should not be what we expected that the third partition has no index. That is to say, when our CIC goes wrong, either roll back all or go down instead of stopping in the middle. This is my shallow opinion, please take it as your reference. Thank you very much, Regards, Adger --

Re: how to create index concurrently on partitioned table

2020-06-12 Thread Justin Pryzby
On Fri, Jun 12, 2020 at 04:17:34PM +0800, 李杰(慎追) wrote: > As we all know, CIC has three transactions. If we recursively in n > partitioned tables, > it will become 3N transactions. If an error occurs in these transactions, we > have too many things to deal... > > If an error occurs when an

Re: how to create index concurrently on partitioned table

2020-06-12 Thread Michael Paquier
On Thu, Jun 11, 2020 at 10:35:02AM -0500, Justin Pryzby wrote: > Note, you could do this now using psql like: > SELECT format('CREATE INDEX CONCURRENTLY ... ON %s(col)', a::regclass) FROM > pg_partition_ancestors() AS a; > \gexec I have skimmed quickly through the patch set, and something has

Re: how to create index concurrently on partitioned table

2020-06-11 Thread Justin Pryzby
On Sun, Jun 07, 2020 at 01:04:48PM -0500, Justin Pryzby wrote: > On Sat, Jun 06, 2020 at 09:23:32AM -0500, Justin Pryzby wrote: > > On Wed, Jun 03, 2020 at 08:22:29PM +0800, 李杰(慎追) wrote: > > > Partitioning is necessary for very large tables. However, I found that > > > postgresql does not