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 1fIJCJ-0004YD-2d for pgsql-general@arkaria.postgresql.org; Mon, 14 May 2018 19:31:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fIJCH-00011V-8M for pgsql-general@arkaria.postgresql.org; Mon, 14 May 2018 19:31:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fIJCG-00011D-UJ for pgsql-general@lists.postgresql.org; Mon, 14 May 2018 19:31:49 +0000 Received: from mail-qk0-x230.google.com ([2607:f8b0:400d:c09::230]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fIJCE-0003Pu-5Z for pgsql-general@lists.postgresql.org; Mon, 14 May 2018 19:31:48 +0000 Received: by mail-qk0-x230.google.com with SMTP id b22-v6so5123483qkj.9 for ; Mon, 14 May 2018 12:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=IdFqq5a8ZfLs01tKrdNCv8Yyk5lUzhgOiv5XayU6prM=; b=Q2ILuBTwqAu4GM58Q8HiZMyUQ3AzU10jPAOnBYlC2kxNCc72Vq3buJV0mcpZE2lp26 fcKF5Kz8lyGnXh7aYTLbhrF4TCguySk1Q7iqytJFfzeMAfL3rkZUNkDC6Uyb0FlBwEkH Dk6RCwnEJFpKByJHuVXG52EASizUQwP+UY9UoMboboKU7GmtRGRWGc7IChHENS9HBv6Y ZoZ8ZIWne2/hichrQkdbu+7rLweTi+oIM5vqC07mWu3zJ4plTDgNVr+0CQ/q2Kqvydk6 fQwINQDXIrfqe6MIp0qUI1sqeTzGMP99SdKaJO9hoxrW+EMl27gHktoSIM6PLtMmtIkR uACA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=IdFqq5a8ZfLs01tKrdNCv8Yyk5lUzhgOiv5XayU6prM=; b=oOBT2StSTy54YPaK7fQ+OlKYYVeKeXBS5JxvjBFAt0ScXMPnFsgyXXPC/0c4Ke0efl slQSGmtZRXrWW6Py7u+EEQaynkCKmSCcUnJQDboNszNWh79c5xwZpTvAEQxc5AbUPN2l 0ssFM/m8OsNbTHTOTjQ501XzINsw8Txk839b555qPter+9veFkTaHmqFef2P7zyK9eyU l6UJAdWH/xtg5jcU/gagkT64Hut2FYafinjhyODAlvGKaQqvXxfuvCkVtX5nv3dGGdiI LjjlWKnz2X1D69p68KC52zZvCRlgZC23lE6FadfiONU3UB9XOzs1Gtxo91Vka70lxT74 iKGg== X-Gm-Message-State: ALKqPwcaU6w9XwLXsOsJ+fZfuS4/cBz5uRDocYmWqoUW3UTJQiqTFsmO WG1XKJCHNbAWqMtsZsYojdg= X-Google-Smtp-Source: AB8JxZpvVQ5NPI9kKXIPikkoTMqcxuMYfADcUXFQ1/A+FOWuWagaLSIwqrs9g8a0uBJ+NyWOKM8ffA== X-Received: by 2002:a37:ab0b:: with SMTP id u11-v6mr9163690qke.82.1526326303543; Mon, 14 May 2018 12:31:43 -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 v65-v6sm5491256qkb.91.2018.05.14.12.31.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 12:31:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: Rapid disk usage spikes when updating large tables with GIN indexes From: Jonathan Marks In-Reply-To: <31807.1526324895@sss.pgh.pa.us> Date: Mon, 14 May 2018 15:31:42 -0400 Cc: pgsql-general@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <3F92DA72-F04E-4154-AB04-B2792DD904F1@gmail.com> References: <26217.1526318186@sss.pgh.pa.us> <31807.1526324895@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3445.5.20) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk We=E2=80=99ll turn on log_temp_files and get back to you to see if = that=E2=80=99s the cause. Re: the exact queries =E2=80=94 these are just = normal INSERTs and UPDATEs. This occurs as part of normal database = operations =E2=80=94 i.e., we are processing 10% of a table and marking = changes to a particular row, or happen to be inserting 5-10% of the = table volume with new rows. Whenever we bulk load we have to drop the = indexes because the disk space loss just isn=E2=80=99t tenable. Re: extra disk space consumption not within PG =E2=80=94 the AWS folks = can=E2=80=99t tell me what the problem is because it=E2=80=99s all = internal to the PG part of the instance they can=E2=80=99t access. = Doesn=E2=80=99t mean your last suggestion can=E2=80=99t be the case but = makes it slightly less likely. Any chance that GIN indexes are double-logging? I.e. with fastupdate off = they are still trying to keep track of the changes in the pending list = or something? Our thought has been temp files for a while, but we=E2=80=99re not sure = what we should do if that turns out to be the case. > On May 14, 2018, at 3:08 PM, Tom Lane wrote: >=20 > [ please keep the list cc'd ] >=20 > Jonathan Marks writes: >> Thanks for your quick reply. Here=E2=80=99s a bit more information: >> 1) to measure the =E2=80=9Csize of the database=E2=80=9D we run = something like `select datname, = pg_size_pretty(pg_database_size(datname)) from pg_database;` I=E2=80=99m = not sure if this includes WAL size. >> 2) I=E2=80=99ve tried measuring WAL size with `select sum(size) from = pg_ls_waldir();` =E2=80=94 this also doesn=E2=80=99t budge. >> 3) Our current checkpoint_timeout is 600s with a = checkpoint_completion_target of 0.9 =E2=80=94 what does that suggest? >=20 > Hmph. Your WAL-size query seems on point, and that pretty much = destroys > my idea about a WAL emission spike. >=20 > pg_database_size() should include all regular and temporary = tables/indexes > in the named DB. It doesn't include WAL (but we've eliminated that), = nor > cluster-wide tables such as pg_database (but those seem pretty = unlikely > to be at issue), nor non-relation temporary files such as sort/hash = temp > space. At this point I think we have to focus our attention on what = might > be creating large temp files. I do not see anything in the GIN index = code > that could do that, especially not if you have fastupdate off. I = wonder > whether there is something about the particular bulk-insertion queries > you're using that could result in large temp files --- which'd make = the > apparent correlation with GIN index use a mirage, but we're running = out > of other ideas. You could try enabling log_temp_files to see if = there's > anything to that. >=20 > In the grasping-at-straws department: are you quite sure that the = extra > disk space consumption is PG's to begin with, rather than something > outside the database entirely? >=20 > regards, tom lane