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 1m4PZN-0002xe-Rx for pgsql-general@arkaria.postgresql.org; Fri, 16 Jul 2021 15:16:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m4PZM-0005NN-SN for pgsql-general@arkaria.postgresql.org; Fri, 16 Jul 2021 15:16:04 +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 1m4PYA-0003bc-G9 for pgsql-general@lists.postgresql.org; Fri, 16 Jul 2021 15:14:50 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m4PHx-00048G-Ne for pgsql-general@postgresql.org; Fri, 16 Jul 2021 14:58:06 +0000 Received: by mail-wm1-x32e.google.com with SMTP id f190so4455185wmf.4 for ; Fri, 16 Jul 2021 07:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=+0fgrjMgafNq6odAfZjmDk3q4Lk2p2JDzyGJT1UhDqE=; b=KQi8Bj/OdfHLbGHvmmdGtJbLF1QLP9m5KArRbvfGcZyB3yc0Lq2f9cTVZSVQvSTkdd GytkIiwDzxvGWhxsmbtbN2yUglYSTdpB4jTt7Jq2v2DR7zUeZeO1cyewC4q3P4d1sl5A Du6zP+AdwqAAfJ64eJ7DLXXmshKGlW1/UJZ1jj+t4w+ZPivkqJ8lxSTM6D+kgSFZ9F7I gtYo9WEFRk1S5FMb+D8fzGoSf3QY7bgEb+QEvtIVTGkhPRk1Ep0hUZpv8WQ9fe6QexCK CCVGiF+rpMn0tAl68EzkFe8z6LeGsvZyEFGT/g141Tg+nZniSh+1aNYwxlmBoKuAFWSp bZmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=+0fgrjMgafNq6odAfZjmDk3q4Lk2p2JDzyGJT1UhDqE=; b=hCeLTaKmz+1jyb8HDIaNBXpKDLCXkVBaRyg4CVwEg1MuthArWVPpOuYEQ1M4Ayvskr c4m22pfsgH+LVeF9vnguXV1J8yf94kgBxXHm3AroGzDYaOAQIvLgkhAx5a12iYiggzzy L0lMHsjmc5M6iW/qGfMX4PvqPj90ffxZoaT3YltWUq35W6wsXgIhjqhO9QBt6u2ei8Lv 81Gn/Dgos5jTDsAFavomg/HubOE8dBSHaYc3GbfbUsBN3APXZSEH1p5MZnJ0D985yKDn hWqDbkFd4ncR9J47wz1HWTCOJgyZy3aLJkyMffzNeeymV1lYpedmJ5svxgMin84cN973 vogg== X-Gm-Message-State: AOAM532FZzT1hF/jDbKKgLNXXc0CHBwTNBOfd7X9DLUPeD23O1/tEKfd oIo+oF8LiNw8tN6Y57NHFuw= X-Google-Smtp-Source: ABdhPJyOTMXz/++Mknu16FvtKYGSNWVLifQV/jRbs2Q1LHDNEHOr4b/JefsOEAi0bknN4JZhp4I2AA== X-Received: by 2002:a05:600c:2255:: with SMTP id a21mr11098498wmm.90.1626447482838; Fri, 16 Jul 2021 07:58:02 -0700 (PDT) Received: from toms-imac.volo.voidbridge ([80.87.23.218]) by smtp.gmail.com with ESMTPSA id o28sm11226631wra.71.2021.07.16.07.58.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jul 2021 07:58:02 -0700 (PDT) From: Tom Dearman Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_18A88EC7-C457-4E73-B87C-928AF8710FE1" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Frequetly updated partial index leads to bloat on index for Postresql 11 Date: Fri, 16 Jul 2021 15:58:01 +0100 In-Reply-To: Cc: Peter Geoghegan , pgsql-general General To: Michael Lewis References: <95D506BA-D1E8-45BB-8167-BD61ED3D9B9C@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_18A88EC7-C457-4E73-B87C-928AF8710FE1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 We have change autovacuum so that it runs more frequently = autovacuum_vacuum_scale_factor=3D0.035, the reason we have a partial = index on the status is that in a table of 300 million entries, only = about 100 or so would have status=3D=E2=80=98IN_PROGRESS=E2=80=99 so we = think this should be a nice small index and many of our queries want to = look up with a where clause status=3D=E2=80=98IN_PROGRESS=E2=80=99. In = theory it works well, but we get a lot of index bloat as there is a lot = of churn on the status value, ie each row starts as IN_PROGRESS and then = goes to one of 4 possible completed statuses.=20 > On 16 Jul 2021, at 15:49, Michael Lewis wrote: >=20 > Have you tried setting autovacuum to run quite aggressively, perhaps = just on this table? Have you tried an index on the status column only, = rather than partial? --Apple-Mail=_18A88EC7-C457-4E73-B87C-928AF8710FE1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 We = have change autovacuum so that it runs more frequently autovacuum_vacuum_scale_factor=3D0.035, the = reason we have a partial index on the status is that in a table of 300 = million entries, only about 100 or so would have = status=3D=E2=80=98IN_PROGRESS=E2=80=99 so we think this should be a nice = small index and many of our queries want to look up with a where clause = status=3D=E2=80=98IN_PROGRESS=E2=80=99.  In theory it works well, = but we get a lot of index bloat as there is a lot of churn on the status = value, ie each row starts as IN_PROGRESS and then goes to one of 4 = possible completed statuses. 

On 16 = Jul 2021, at 15:49, Michael Lewis <mlewis@entrata.com> = wrote:

Have you tried setting autovacuum to run quite = aggressively, perhaps just on this table? Have you tried an index on the = status column only, rather than partial?

= --Apple-Mail=_18A88EC7-C457-4E73-B87C-928AF8710FE1--