Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pmTlR-0003VB-3u for pgsql-admin@arkaria.postgresql.org; Wed, 12 Apr 2023 06:15:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pmTlP-0000NH-TU for pgsql-admin@arkaria.postgresql.org; Wed, 12 Apr 2023 06:15:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pmTlP-0000N8-Dz for pgsql-admin@lists.postgresql.org; Wed, 12 Apr 2023 06:15:27 +0000 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pmTlL-00059e-0B for pgsql-admin@lists.postgresql.org; Wed, 12 Apr 2023 06:15:26 +0000 Received: by mail-wr1-x431.google.com with SMTP id o18so9721841wro.12 for ; Tue, 11 Apr 2023 23:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; t=1681280120; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Lu23YuWqYlQXXPcGlt5fxRKtDfDfQim1qPWJa3yfhY0=; b=ihSFJKpma5boRb+YQbtk2e6+vv3OCiM0yU0PI7GTbyXud4rsDniFsixFp2IxZ42/yC rcQcMpBEtabRDRQO2wp8J/APR7GdoHs+A0G6n1+Q555p3XFAnqbfOt+wh9ZXobBPOS4D 9KQbZiBjuz/rCQQeSgXLsq8tmrXYOLXSrt3MnCmg/I4Z5mYW8uUan5QDgiQvRUoCfm+P KXZw/byL46i7x6xnD6c3FOR/anOpsXVUun4R/QbKeVSq6Us5ZKEmiQmLYBMxqDlwfAUP 8Tzdfz4q2NFZ1PlmqO+I1VY2FlzAb/a5Deoi3DMIxKdMrkJIQEBxE7/HPkA0L7VRxzHy j4HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681280120; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Lu23YuWqYlQXXPcGlt5fxRKtDfDfQim1qPWJa3yfhY0=; b=B7ybLxemcXMBlbyl/OtJ248l9aSYKKokALk5doEDgqY4qodNWF2vouXM+DZQp7YXm+ z7pTEq+2ACZyB2gSKlacwEw823wkhMs7u5lV7rTHe0/2Vld7Rfud/LLnEQcuOo1rdBR+ VRidglvTx4MfL0TzuUYNnHbMf3RZfmV22nMvAmsRVT6BwBZ7Oo5CxmjJ9SZiBZIvnXGS UkgRffwtQa6aINIazij1DRoVuKaxc2Jjo2/f4/NeW1mVmmDS5PzEGWOFjhvVyZTqfvuw 3AyoZqBq7iUz32jGnIkoVn74RpXgRahoC09QOWqS40piQiCPaXHqEvN4ieQzYXjXEvLH hDCA== X-Gm-Message-State: AAQBX9fxWA0vlOBab7zQ+Ds/wVJMmEPt1kAyxrIhXk0xMpoO+dvyfCYs ejqhRGsaPwxdiIcc94GNVqE3+A== X-Google-Smtp-Source: AKy350ZZ2/jEnc9mEd5OuedtsWM3Ow2R04yJeET+0Qul29xHphTzdZrd3BaAmEC7SfrSp7EaPP7Rwg== X-Received: by 2002:a5d:66cb:0:b0:2f2:c46b:1eb5 with SMTP id k11-20020a5d66cb000000b002f2c46b1eb5mr3865013wrw.59.1681280120604; Tue, 11 Apr 2023 23:15:20 -0700 (PDT) Received: from localhost.localdomain ([2001:871:5e:8441:29ff:482:b177:ca5b]) by smtp.gmail.com with ESMTPSA id b16-20020adfe310000000b002f27a6a49d0sm5159236wrj.10.2023.04.11.23.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Apr 2023 23:15:20 -0700 (PDT) Message-ID: <774f65350020e246daee7ffa726a9709c3122044.camel@cybertec.at> Subject: Re: attach partition to parent table with default partition accessexclusive From: Laurenz Albe To: "James Pang (chaolpan)" , "pgsql-admin@lists.postgresql.org" Date: Wed, 12 Apr 2023 08:15:19 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2023-04-12 at 03:03 +0000, James Pang (chaolpan) wrote: > We have a table=C2=A0=C2=A0=C2=A0 wbxdata (xxxx=E2=80=A6)=C2=A0 partition= by range(starttime) , and have a > default partition, now we want to add a new partition and move the data f= rom > default partition to new added partition. > =C2=A0 > Begin;=20 > =C2=A0=C2=A0Alter table only=C2=A0 wbxdata =E2=80=A6 detach partition=C2= =A0 wbxdata_pdefault; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0---from here, accessexclusive lock on wbxdata_pdefault default partition= , and it block all query on parent table wbxdata. > =C2=A0Insert into wbxdata_p2305 select * from wbxdata_pdefault where star= ttime >=3D =E2=80=982023-05-01 00:00:00=E2=80=99::date and starttime < =E2= =80=982023-06-01 00:00:00=E2=80=99; > Delete from wbxdata_pdefault where starttime >=3D =E2=80=982023-05-01 00:= 00:00=E2=80=99::date and starttime < =E2=80=982023-06-01 00:00:00=E2=80=99; > Alter table only wbxdata attach partition wbxdata_p2305 for values from = =E2=80=98=E2=80=982023-05-01 00:00:00=E2=80=99 TO =C2=A0=E2=80=982023-06-01= 00:00:00=E2=80=99; > Alter table attach default partition; > End; > Is it expected to see all query even select on=C2=A0 parent table=C2=A0 w= bxdata got blocked , > when=C2=A0 detach default partition and attach default partition ? > Postgresql 14.7 version. Yes, that is expected. I recommend not to use a default partition if you want to attach more parti= tions later. Yours, Laurenz Albe