Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v6P2B-0040wo-Bx for pgsql-admin@arkaria.postgresql.org; Wed, 08 Oct 2025 07:56:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v6P29-008OY8-4e for pgsql-admin@arkaria.postgresql.org; Wed, 08 Oct 2025 07:56:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v6P28-008OXz-Oa for pgsql-admin@lists.postgresql.org; Wed, 08 Oct 2025 07:56:25 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6P27-00106N-0S for pgsql-admin@lists.postgresql.org; Wed, 08 Oct 2025 07:56:25 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-b3dbf11fa9eso1291787166b.0 for ; Wed, 08 Oct 2025 00:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1759910180; x=1760514980; darn=lists.postgresql.org; 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=dK1th2GoccrjlSMxvWi5yn5ry0sbluDvsVToRoen6/g=; b=sGt9nBjnyEXvl8as+K3R1IMtk3QDVvwvmnfIKoX1bYC0Rpk+Gz/NbyuUNdHWA57O9a ieikoHJuaca8VtEF/hdZqSmNKuKcsuoHLvV8CcEw6/ub4t6sfjFep67bIVo7wMbItDsb SmO6DwewkpT83+znH7FwNYDMaZ+AzES1KSNOm9eAWyTMwy0tnAYVMfYyuA7qcevgzSAK 4r4/xm52KfQQdgRaviutgzBQf7iuml9jJFmAOBhxu35BUVQwLHO916/KG93pXwTpgFf9 8Uj+TLL08cjgoT0Blu/SrDyNdC8D6k/K2dIyEwUc9UvJZB6gRa3OweOQhwcK+E6tjuea m65A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759910180; x=1760514980; 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=dK1th2GoccrjlSMxvWi5yn5ry0sbluDvsVToRoen6/g=; b=lpu7XD6AIVcON+yHjcxXBN/Axkt3j0MFIhYF1A3SnP3xObH0D40a199wOhOyshWmCk MN2nvHspIqiZ8byMKE2S8QHYzz2iS1j7nwLFfCdHywjDUbUzMyhDEdznOuV6EyTXGlNq 65f4NmCDEUf6qofzYvbIE3eb9G9zbDLvfPMRE+Oxm0XWc7RxPddrNo5tOJShHgy0unTL JZeHdqUbmBI0dKxNWmIiaAb3MjQcywpdFfxuaeDw/j37Cq4Ol8PGA7rbe5ef55l5JJoi 7SE9WhNLORNt8lJKXbnX4ThhzO81vc/6P5qZjqmOs2NvHWNYHH/Xo+eLR8hOsEVVO+HA JVIA== X-Forwarded-Encrypted: i=1; AJvYcCVbo0HR899wpnXY2XrNE3VuR3JTbEZ4rtfMqUUL9qEbt+OMcZcumD4pLobXyYHbw5X+VXWIhk5vb6UYlA==@lists.postgresql.org X-Gm-Message-State: AOJu0YyJcNBhPsGOsrw695iBaq/H1IlyEUXZqo7WhobrDQQGwtZBId1t OtiQCAAyH95GZIvW/7RqZduzebcHZXAvNrLhrRcZKBs33HvIZIll6bkBGKK+4oNgUmQ= X-Gm-Gg: ASbGncvqBusce58UFV2NN/z5njpemA7AgEKCb0840Gnw2go6kfTVZ2nFNTdFICC8YNQ A+O4RO/T7lK1yB6YsKRlAGPeTmCSXw4zUfA/IaVNomdOl0H8omwa6hmS0RtlqwqdNyygKFOvUix 6zfLrHnrfTnvjNYTQxLca5ps3FgwgO0nBSNQQhWJX+CyanW8NMbheHG4wyOpeB5dNlWYRA9k/ZS dEsXYEOLVdg8gVFMH6C3PEsh7kyqfG0KbcHEU3n3sq0NRLQn8+Oq45uyatp4bfAuUH6TvQRmn9i 8LOhs2FB2EAH5BXKaFqcFa3GLXmdDPCOKJ7FfB0xAfmL4IbpjhuNB6wrAEOI0vwjkpTae0amQr+ Wm2Jmb2cMjApaRLrZdRbWnvbskWQl0TnpZmWbqXSmk7Mz3AH6GKp+5NKo3IRFYDvYveq9QXzgh1 r0r+2Ky/rfZsM= X-Google-Smtp-Source: AGHT+IEpdpEyFFZMePCmjitV3k/7uB3ijPfZ9gmhyfiBWPXXIKbtsJVFQsvMfjZt07qq02iBDKn45Q== X-Received: by 2002:a17:907:3fa7:b0:b42:365:3199 with SMTP id a640c23a62f3a-b50aaba1cb6mr285116366b.25.1759910179914; Wed, 08 Oct 2025 00:56:19 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([88.116.133.170]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b486a173a5dsm1600489066b.85.2025.10.08.00.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Oct 2025 00:56:19 -0700 (PDT) Message-ID: Subject: Re: Dropping index from large, partitioned table From: Laurenz Albe To: Matthew Planchard , pgsql-admin@lists.postgresql.org Date: Wed, 08 Oct 2025 09:56:18 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-10-07 at 17:00 -0400, Matthew Planchard wrote: > I have a very active table with around 1,000 partitions. I would like > to drop a GIN index on one of its columns. >=20 > Unfortunately, this is a top-level index, and so it seems impossible > to drop the indexes on each partition individually, which means a > 'drop index' requires holding an access exclusive lock on the entire > table until the process completes for all children. That process turns > out to be much too slow, since it requires locking one of our most > read and written to tables for the duration. >=20 > In one of our larger environments, I attempted a drop with a > two-minute timeout, with no success, and two minutes is really pushing > what we're able to do without causing really obvious downtime. >=20 > Some additional context is that our production deploys are in RDS, so > even with an admin user I am not able to modify the postgres system > tables to do things like marking indexes as invalid. >=20 > Is there any way to manage this without requiring the massive global > access exclusive lock for the duration of the drop on every child > partition? I don't think there is, and if you are using a hosted database, you are free from the temptation to mess with the catalogs manually and risk destroying your database. I don't think that the actual DROP INDEX will take long (you could run it on a test system), the challenge is to quiesce the application. Take a down time of five minutes, shut down the application, run your DROP INDEX, check with pg_blocking_pids() if there are any stragglers that are locking you out and kill them with pg_terminate_backend(). Yours, Laurenz Albe