Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fIGKc-0005p1-IE for pgsql-general@arkaria.postgresql.org; Mon, 14 May 2018 16:28:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fIGKa-0007Zq-JR for pgsql-general@arkaria.postgresql.org; Mon, 14 May 2018 16:28:12 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fIGKa-0007Zg-5k for pgsql-general@lists.postgresql.org; Mon, 14 May 2018 16:28:12 +0000 Received: from mail-qt0-x231.google.com ([2607:f8b0:400d:c0d::231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fIGKX-00088d-KJ for pgsql-general@postgresql.org; Mon, 14 May 2018 16:28:10 +0000 Received: by mail-qt0-x231.google.com with SMTP id q6-v6so16917456qtn.3 for ; Mon, 14 May 2018 09:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=SDNfTJDpDil14DV5n7zBIhKabkoDewNlq02rpb+nXvE=; b=AKktxR6biyh3cjNBYHUSIUgt+MhqT0Dzdr8xw1KCnRXCkk92Z7QGNYMaw5FlyPMaIH YxrZGRN/r5VwJLU/Qy1jUKta10IOOHyIJ5voLr1aQz0Y7ayfjgpCzPvtclD1UJZ/xdIF 7+Om4PnANaOnK8RkXvZvCnbhfC2Pn1IdO9i1sH1RJ9HiGGXyPMSbNcdQCu0Q0zmEu8+c kHb77yxYkv9FCNc3Y7aVbOYf2+sq2CfQ/EbevY+ksmf/4w/RySJxN2rJ/SqxBP/7gpQe dSo0CiVUr0W77iZi7Rb5DUZ/QUXDFniyjvpRTlNDG/mgT2FkMLOYjP6xU8fIm74v/XHY BFjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=SDNfTJDpDil14DV5n7zBIhKabkoDewNlq02rpb+nXvE=; b=BY/hIublDjo3S5qUryQg+r+Y/ijDFG0tjQKsunp3Mi8n4jj94GYQa0mFLrlnIgYmGZ FLWLeLYPSsgHhpFJMC4F+/6KxR+CLIBUSxL/Jtwuw+lAd/Ds+jm6mg1DkCx/jSEjcU5o +T366rr/2B6Ax2+s9WLa+N+HIEaAPeGE+ql7N/+GBEH4MVzSkPCCev2kJxBRInufFBPM iI0OPQPlh4mxbPTxKcNaAJztV4hMj2EOwFgS2WfkGK/D9WuwzKYO8e2EY2MRModVA3xk YWdYnAdjIsW6no8LPzdGhnmDhSNxszMzO7NbBO0FN1eL1d7NLoHsAiY4Th1nDuY8WWhD Izrg== X-Gm-Message-State: ALKqPwePOmL8zkZsLyP9rn+MdbtNafHRRPdRPZv4d7gN5rDyUGtukr3z Y9qmJvFQkF2Tp4P03QwQ1DMeO/IQ X-Google-Smtp-Source: AB8JxZp1+9YZ/MC9y3xGbQqZDo8zw6odTz+SnvWdOfolO7Neh42+6KJGKTYtB52ciO6bUEpnCPt2Eg== X-Received: by 2002:ac8:361:: with SMTP id w33-v6mr9650021qtg.58.1526315286616; Mon, 14 May 2018 09:28:06 -0700 (PDT) Received: from [192.168.213.53] (50-249-28-57-static.hfc.comcastbusiness.net. [50.249.28.57]) by smtp.gmail.com with ESMTPSA id 26-v6sm8415794qtm.16.2018.05.14.09.28.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 09:28:06 -0700 (PDT) From: Jonathan Marks Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Rapid disk usage spikes when updating large tables with GIN indexes Message-Id: Date: Mon, 14 May 2018 12:28:05 -0400 To: pgsql-general@postgresql.org X-Mailer: Apple Mail (2.3445.5.20) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello! We have a mid-sized database on RDS running 10.1 (32 cores, 240 GB RAM, = 5TB total disk space, 20k PIOPS) with several large (100GB+, tens of = millions of rows) tables that use GIN indexes for full-text search. We = at times need to index very large (hundreds of pages) documents and as a = result our tables have a mix of small (tens of tokens) to very large = (hundreds of thousands of tokens near to the tsvector 1MB limit). All = our GIN indexes have fastupdate turned off =E2=80=94 we found that = turning fastupdate on led to significant blocking and that we get better = average performance with it turned off. We=E2=80=99ve put a lot of = effort into tuning our database over the last several years to the point = where we have acceptable read and write performance for these tables.=20 One recurring, and predictable, issue that we have experienced regularly = for multiple years is that inserting or updating rows in any table with = GIN indexes results in extremely large drops in free disk space =E2=80=94 = i.e. inserting 10k rows with a total size of 10GB can result in the = temporary loss of several hundred gigabytes of free disk space over 2-3 = hours (and it could be more =E2=80=94 we try to keep a 10-15% buffer of = free disk space so that often represents almost all available disk = space). Once we stop the operation, free disk space rapidly recovers, = which makes us believe that this occurs due to logs, or some kind of = temporary table. Our work_mem and maintenance_work_mem settings are = pretty large (12GB and 62GB, respectively). The database=E2=80=99s size = on disk scarcely budges during this process. Unfortunately, we=E2=80=99re on RDS, so we=E2=80=99re unable to ssh = directly into the instance to see what files are so large, and none of = the logs we can see (nor the wal logs) are large enough to explain this = process. Any suggestions about where to look to see the cause of this = problem (or about any settings we can tune or changes we could make to = stop it) would be greatly appreciated. Thank you!=