Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1epFFb-00007A-Qy for pgsql-performance@arkaria.postgresql.org; Fri, 23 Feb 2018 15:27:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1epFFa-0006g0-M3 for pgsql-performance@arkaria.postgresql.org; Fri, 23 Feb 2018 15:27:06 +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.84_2) (envelope-from ) id 1epFFa-0006fq-Bw for pgsql-performance@lists.postgresql.org; Fri, 23 Feb 2018 15:27:06 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1epFFX-0003M9-3K for pgsql-performance@lists.postgresql.org; Fri, 23 Feb 2018 15:27:05 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 1E16640E77; Fri, 23 Feb 2018 16:26:59 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id XDY6F_6tjYHo; Fri, 23 Feb 2018 16:26:56 +0100 (CET) Message-ID: <1519399615.2530.14.camel@cybertec.at> Subject: Re: need advice to tune postgresql From: Laurenz Albe To: Darius =?UTF-8?Q?P=C4=97=C5=BEa?= , pgsql-performance@lists.postgresql.org Date: Fri, 23 Feb 2018 16:26:55 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Darius Pėža wrote: > I have issue that update queries is slow, I need some advice how improve speed. I don't have much control to change queries. But I can change postresql server configuration > > query example: > > UPDATE "project_work" SET "left" = ("project_work"."left" + 2) WHERE ("project_work"."left" >= 8366) > > sometimes updated lines count is up to 10k > > postgresql version 9.3 > > postgresl.conf > max_connections = 100 > shared_buffers = 6GB # min 128kB > work_mem = 100MB # min 64kB > > all other values are default > > server hardware > Intel(R) Xeon(R) CPU E5-2637 v4 @ 3.50GHz > 16GB RAM > disk is HDD > > about half of resource I can dedicate for postgresql server. If the number of updated lines is that big, you should try to get HOT updates as much as possible. For that, make sure that there is *no* index on the column, and that the fillfactor for the table is suitably low (perhaps 50). During a HOT update, when the new row version fits into the same page as the old one, the indexes don't have to be updated. That will speed up the UPDATE considerably. On the other hand, an UPDATE like yours would then always use a sequential scan, but that may still be a net win. Other than that, setting checkpoint_segments high enough that you don't get too many checkpoints can help. Of course, more RAM and fast storage are always good. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com