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 1hxaNo-0004rP-F9 for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 17:14:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxaNn-0006Lv-4v for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 17:14:51 +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 1hxaNm-0006Hk-PD for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2019 17:14:50 +0000 Received: from smtp32.i.mail.ru ([94.100.177.92]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxaNj-0001Dd-NO for pgsql-general@postgresql.org; Tue, 13 Aug 2019 17:14:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:References:Cc:To:From:Subject; bh=m/vM1wOx7POjWSEDsVqY6oElp9VLgoBlxY7S8lhLydM=; b=H2fBd7iPVQaHf7bM0CTbPBUPahCD49Fj600Gx16wrfcCOL3kgFtwqeEQJYYrh402YQwEpwJwYis7mZe73F0X28uLVzQt6gvB4D9BDyJrr77KANQAYQIPxkmh4gPu69oG9UoWdV9H1DAyzPwJk4/PtjweZVA4qYRCrmZ1a7+G9A4=; Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1hxaNi-0006Fz-71; Tue, 13 Aug 2019 20:14:46 +0300 Subject: Re: Changing work_mem From: rihad To: Luca Ferrari Cc: Peter Eisentraut , pgsql-general General References: <2cbec921-a0c2-016f-1831-82dd45106af3@mail.ru> <6d170b3b-17b7-8e02-bbf6-2a6885b317eb@mail.ru> <50c20aea-6f63-2cf7-1760-bb28679ff3e7@mail.ru> <9c6b069a-c99b-4b65-92fa-59404012e576@mail.ru> Message-ID: Date: Tue, 13 Aug 2019 21:14:44 +0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <9c6b069a-c99b-4b65-92fa-59404012e576@mail.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: smtp32.i.mail.ru; auth=pass smtp.auth=rihad@mail.ru smtp.mailfrom=rihad@mail.ru X-77F55803: 2D1AD755E866B1545A78504BD2AC2941ABDFC7E166457DED9688FFA0BD7029545A7646039532EC3C2D127546BB1D1FF7 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D6AE5EDF9DDECFEFC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE78FFEDB45F3F2BDECEA1F7E6F0F101C674E70A05D1297E1BBC6CDE5D1141D2B1C8EF6D7983C9358580520A89A8E5A337D6830ED331502DBC39FA2833FD35BB23D9E625A9149C048EE33AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BD4B6F7A4D31EC0BB23A54CFFDBC96A8389733CBF5DBD5E9D5E8D9A59859A8B6D082881546D93491CC7F00164DA146DA6F5DAA56C3B73B23E7DDDDC251EA7DABD81D268191BDAD3DC09775C1D3CA48CF5973B86847D985D276E601842F6C81A12EF20D2F80756B5FBBC930A3941E20C63AA81AA40904B5D98AA50765F7900637E2F9C2D87DC0560AB3661434B16C20ACC77107234E2CFBA522CA9DD8327EE4930A3850AC1BE2E7356909857A1D682E497569CFF5BA9873C2731C566533BA786A40A5AABA2AD371193C9F3DD0FB1AF5EBE26B79914A659FB62623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-Mailru-Sender: B19AB4DAF1EA2FB5AD9FC17C94DC39F5DA347BF705C28430A7C81EC44FD9B2D9EF14E3EC3073B184ABBFE0CF075BC50BFB559BB5D741EB96004FA9CEFBA991DA3A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: OK List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 08/13/2019 09:04 PM, rihad wrote: > On 08/13/2019 08:44 PM, rihad wrote: >> On 08/13/2019 08:22 PM, Luca Ferrari wrote: >>> On Tue, Aug 13, 2019 at 5:59 PM rihad wrote: >>>> [dbname] LOG:  temporary file: path >>>> "base/pgsql_tmp/pgsql_tmp93683.257381", size 594 >>>> >>> The setting 'work_mem' is within context 'user', that means it will >>> affect running sessione unless the session itself has already issued a >>> SET work_mem to xxx. >>> So this could be a reason why you don't seem to see any change. >>> >>> Also keep in mind that work_mem work on a connection basis, so you are >>> going to possibly see 521MB x num_connections if all your clients are >>> doig the same kind of sort concurrently, which probably causes >>> PostgreSQL to go to disk due to memory unavailable. >>> >>> Hope this helps. >>> Luca >>> . >>> >> Thanks. The box has 15GB mem free (as in FreeBSD ))) >> >> And it hasn't moved a notch after the increase. >> >> No code does SET work_mem=... AFAIK. >> >> My apologies to Mr. Peter but I still think that older processes, >> some of them started a couple of weeks ago, use the older setting. > Sorry, I just decreased work_mem back to 256MB, reloaded, and > instantly started seeing 82mb temp file creation, not 165mb as was > usual with work_mem=512MB. > > So it indeed was applied immediately. > Really weird figures ) Increased work_mem to 768MB and start seeing temp file creation log entries 331MB in size. Bizzare ) It looks like the bigger it gets, the bigger temp files are created. Why not decrease it to 64mb then...