Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdGjj-0002dK-NN for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 16:13:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hdGji-0004J0-Ik for pgsql-general@arkaria.postgresql.org; Tue, 18 Jun 2019 16:13:30 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdGji-0004It-7Q for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2019 16:13:30 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hdGjb-0002dL-TN for pgsql-general@lists.postgresql.org; Tue, 18 Jun 2019 16:13:29 +0000 Received: by mail-wm1-x342.google.com with SMTP id c66so3971581wmf.0 for ; Tue, 18 Jun 2019 09:13:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ocado.com; s=google; h=reply-to:subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SV8UkXRboQ0XtGX2WyD2Ug7yeg8/FUFul3JW7lGJRUk=; b=4PGwcCQtqPT5XLdMgA8l1l1fL7hnF1T+BCWDzorcMEyumQ9+VjhSmHxvm2M/rTbn/r pOiaiG/DedPPAxw7YwCDCl6xpCqT6lI8NozIL1y8eQmsaz2AL2cI7I93zw02c5BcKw5Y +Lo6N/saLU+8qOYkAihCJ+pkn/J22cYXwINdeeQkoAJHpaZPP6d3Xk3kQFWu3apaIWzo ZLJAZQynUXsGjiDMQ6PY8B/vIzJX/5WTrVTwrjxHFLHvIYjwlXTepZtvUMhivtWwGdwx OUFDu8OVI72sX3DDqfAb53uy+ge9Onvb/5ifmrlRsgoD2uCT/pkIJA/ytqR2imQBBUNX yiXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=SV8UkXRboQ0XtGX2WyD2Ug7yeg8/FUFul3JW7lGJRUk=; b=TcNk7JFKGR98X9fXcSRSorj9s7PoC8Tq0qT714LR/HaoSM45EmOilVbCSuZSDk9LDm 4e/M0SW97HWgDLuIbmjZsO9aDaLXnQr7VJ2CX0X06DhxUHgp63PUXyUf6R9Id8uNpiHd 06iw2arIKHm83kD53j8xxCSqCG/kxe/I+jw+60ImkKs1+xtxE59MRn9gu1ta+JTVzgGv S6SwtqRL8tKiojhJs6pyqOL1oagxeni2ObYx1xsAyeWm5VUF78QPvdrIPnSPDUP7kMMC DkcHlU6UIYphqxglbjFnaHJ6j9crMXVlgsHH1cRUMA56G1t6QoWwwmSZfwnA1nRsQlnC pGLw== X-Gm-Message-State: APjAAAUbGhpxDvLcH2vTpgOtfjS32X43qbn4YwGAuHRVOKr9AxWcmnSN brQsDRKD5xEWjyhTvUWZEFQfrHUHINESEm885aG409Zm+594ms+FRQmAYaPFoFf7Zt/j8B1Lzh9 Dg2ELCZ2Sc54Td1mBQpkiDMmZ6PQYuw== X-Google-Smtp-Source: APXvYqz2hjj/yEwH6Qosq7OPBb5FJAVUs+R/AHX3VVxCpT1jvgBWWX4MQ4pFYFCkPeoU6qxs2vVt9Q== X-Received: by 2002:a05:600c:2243:: with SMTP id a3mr4198551wmm.83.1560874402109; Tue, 18 Jun 2019 09:13:22 -0700 (PDT) Received: from [10.62.14.33] ([91.206.0.63]) by smtp.gmail.com with ESMTPSA id y133sm4302579wmg.5.2019.06.18.09.13.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Jun 2019 09:13:21 -0700 (PDT) Reply-To: f.venchiarutti@ocado.com Subject: Re: perf tuning for 28 cores and 252GB RAM To: Jeff Janes , Michael Curry Cc: pgsql-general References: From: Fabio Ugo Venchiarutti Organization: Ocado Technology Message-ID: Date: Tue, 18 Jun 2019 17:13:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 18/06/2019 00:45, Jeff Janes wrote: > On Mon, Jun 17, 2019 at 4:51 PM Michael Curry > wrote: >=20 > I am using a Postgres instance in an HPC cluster, where they have > generously given me an entire node. This means I have 28 cores and > 252GB RAM. I have to assume that the very conservative default > settings for things like buffers and max working memory are too > small here. >=20 > We have about 20 billion rows in a single large table.=20 >=20 >=20 > What is that in bytes?=C2=A0 Do you only have that one table? >=20 > The database is not intended to run an application but rather to > allow a few individuals to do data analysis, so we can guarantee the > number of concurrent queries will be small, and that nothing else > will need to use the server. Creating multiple different indices on > a few subsets of the columns will be needed to support the kinds of > queries we want. >=20 > What settings should be changed to maximize performance? >=20 >=20 > With 28 cores for only a few users, parallelization will probably be=20 > important.=C2=A0 That feature is fairly new to PostgreSQL and rapidly=20 > improving from version to version, so you will want to use the last=20 > version you can (v11).=C2=A0 And then increase the values for=20 > max_worker_processes, max_parallel_maintenance_workers,=20 > max_parallel_workers_per_gather, and max_parallel_workers.=C2=A0 With the= =20 > potential for so many parallel workers running at once, you wouldn't=20 > want to go overboard on work_mem, maybe 2GB.=C2=A0 If you don't think all= =20 > allowed users will be running large queries at the same time (because=20 > they are mostly thinking what query to run, or thinking about the=20 > results of the last one they ran, rather than actually running queries),= =20 > then maybe higher than that. >=20 > If your entire database can comfortably fit in RAM, I would make=20 > shared_buffers large enough to hold the entire database.=C2=A0 If not, I= =20 > would set the value small (say, 8GB) and let the OS do the heavy lifting= =20 > of deciding what to keep in cache. Does the backend mmap() data files when that's possible? I've heard the "use the page cache" suggestion before, from users and=20 hackers alike, but I never quite heard a solid argument dismissing=20 potential overhead-related ill effects of the seek() & read() syscalls=20 if they're needed, especially on many random page fetches. Given that shmem-based shared_buffers are bound to be mapped into the=20 backend's address space anyway, why isn't that considered always=20 preferable/cheaper? I'm aware that there are other benefits in counting on the page cache=20 (eg: staying hot in the face of a backend restart), however I'm=20 considering performance in steady state here. TIA If you go with the first option, you > probably want to use pg_prewarm after each restart to get the data into= =20 > cache as fast as you can, rather than let it get loaded in naturally as= =20 > you run queries;=C2=A0 Also, you would probably want to set random_page_c= ost=20 > and seq_page_cost quite low, like maybe 0.1 and 0.05. >=20 > You haven't described what kind of IO capacity and setup you have,=20 > knowing that could suggest other changes to make.=C2=A0 Also, seeing the= =20 > results of `explain (analyze, buffers)`, especially with track_io_timing= =20 > turned on, for some actual queries could provide good insight for what=20 > else might need changing. >=20 > Cheers, >=20 > Jeff --=20 Regards Fabio Ugo Venchiarutti OSPCFC Network Engineering Dpt. Ocado Technology --=20 Notice: =C2=A0This email is confidential and may contain copyright material= of=20 members of the Ocado Group. Opinions and views expressed in this message=20 may not necessarily reflect the opinions and views of the members of the=20 Ocado Group.=C2=A0 =C2=A0 If you are not the intended recipient, please notify us=20 immediately and delete all copies of this message. Please note that it is= =20 your responsibility to scan this message for viruses.=C2=A0 =C2=A0 Fetch and Sizzle=20 are trading names of Speciality Stores Limited and Fabled is a trading name= =20 of Marie Claire Beauty Limited, both members of the Ocado Group. =C2=A0 References to the =E2=80=9COcado Group=E2=80=9D are to Ocado Group plc (reg= istered in=20 England and Wales with number 7098618) and its subsidiary undertakings (as= =20 that expression is defined in the Companies Act 2006) from time to time. = =C2=A0 The registered office of Ocado Group plc is=C2=A0Buildings One & Two, Tride= nt=20 Place, Mosquito Way, Hatfield, Hertfordshire, AL10 9UL.