Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dhNhB-0004ZB-N6 for pgsql-performance@arkaria.postgresql.org; Mon, 14 Aug 2017 22:18:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dhNhA-00014W-Au for pgsql-performance@arkaria.postgresql.org; Mon, 14 Aug 2017 22:18:48 +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 1dhNfP-0006KT-Ce for pgsql-performance@postgresql.org; Mon, 14 Aug 2017 22:16:59 +0000 Received: from resqmta-po-07v.sys.comcast.net ([2001:558:fe16:19:96:114:154:166]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dhNfH-0007Y6-UZ for pgsql-performance@postgresql.org; Mon, 14 Aug 2017 22:16:57 +0000 Received: from resomta-po-02v.sys.comcast.net ([96.114.154.226]) by resqmta-po-07v.sys.comcast.net with ESMTP id hNegd3v87T3yqhNfFdyq9V; Mon, 14 Aug 2017 22:16:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t=1502749009; bh=QoXJ59+3IVHXM5il74p5UDRsqrb4cSaDpywi+QM8LQ8=; h=Received:Received:Received:From:To:Subject:Date:Message-ID: MIME-Version:Content-Type; b=Flufo5joWkaWqTFdmGZ4IXHv3/yx2r4+yNqjhY9VQi4YVkomyuRI9LdxMb4U95pA7 LbZOnjZPuSr3bEAKMggoR5Of2ZOtiaCSZRcnns1FcWsA+yG9ptr8Xjd3U0QTOVbZ8S vSyoqphdEM/Qt1B4siwog+aN9iGNg1ctklZj3s6hWT+UuNdAmaq6ET6P5s116V7/HJ pY5Yg2cUAmC/7MpRo8v0wmXIPxuuQl7p2BGti9BLenAJvHFnVMYuKtF4jzBjOPfz+A jfpwM6gfbbJysMC0Yzvpg8dtpeM6WjbxesXx88k4BiJACmvGhYcs/rFnbC36iMOQd1 Iv+yMDLqdCjDw== Received: from jsievers.comcast.net ([12.187.116.132]) by resomta-po-02v.sys.comcast.net with SMTP id hNf2d6laxhI2MhNf4dmDOv; Mon, 14 Aug 2017 22:16:47 +0000 Received: from jsievers.enova.com (localhost [127.0.0.1]) by jsievers.comcast.net (Postfix) with ESMTP id 2B92A26005E; Mon, 14 Aug 2017 17:16:36 -0500 (CDT) From: Jerry Sievers To: Scott Marlowe Cc: Jeremy Finzel , postgres performance list Subject: Re: Odd sudden performance degradation related to temp object churn References: Date: Mon, 14 Aug 2017 17:16:36 -0500 In-Reply-To: (Scott Marlowe's message of "Mon, 14 Aug 2017 14:58:06 -0600") Message-ID: <87r2wdeqwr.fsf@jsievers.enova.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-CMAE-Envelope: MS4wfDVes0T3b7UZqDTjrb/pUbTDOiarDxFK1zjxCQxfKhr46O54hOC8W3SAV1hE0b18BMYUdNCJGZWd2YIKP+cy8Z9fnPYiKodau8oJFK7mkO3JivBIem4f S7indAT5j8j0Sn+unKI1oVz+yn4VIfL4ziqrlBsFjKqous+/QI0eljQ4TP7xogdmPvPBIwfRsnZ2ZtmjUQNtATlsaTueYhp9Nu1CJpGjoWrHeTI4OfltNsl4 przjgAeXAqgczr7gTmbo1LAdejuoHLnwFkXzAd2+NkQ= List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Scott Marlowe writes: > On Mon, Aug 14, 2017 at 2:46 PM, Jeremy Finzel wrote: > >> On Mon, Aug 14, 2017 at 3:01 PM, Scott Marlowe >> wrote: >>> >>> On Mon, Aug 14, 2017 at 1:53 PM, Jeremy Finzel wrote: >>> > >>> > Any insights would be greatly appreciated, as we are concerned not >>> > knowing >>> > the root cause. >>> >>> How are your disks setup? One big drive with everything on it? >>> Separate disks for pg_xlog and pg's data dir and the OS logging? IO >>> contention is one of the big killers of db performance. >> >> >> It's one san volume ssd for the data and wal files. But logging and memory >> spilling and archived xlogs go to a local ssd disk. >> >>> >>> Logging likely isn't your problem, but yeah you don't need to log >>> ERRYTHANG to see the problem either. Log long running queries temp >>> usage, buffer usage, query plans on slow queries, stuff like that. >>> >>> You've likely hit a "tipping point" in terms of data size. Either it's >>> cause the query planner to make a bad decision, or you're spilling to >>> disk a lot more than you used to. >>> >>> Be sure to log temporary stuff with log_temp_files = 0 in your >>> postgresql.conf and then look for temporary file in your logs. I bet >>> you've started spilling into the same place as your temp tables are >>> going, and by default that's your data directory. Adding another drive >>> and moving pgsql's temp table space to it might help. >> >> >> We would not have competition between disk spilling and temp tables because >> what I described above - they are going to two different places. Also, I >> neglected to mention that we turned on auto-explain during this crisis, and >> found the query plan was good, it was just taking forever due to thrashing >> just seconds after we kicked off the batches. I did NOT turn on log_analyze >> and timing but it was enough to see there was no apparent query plan >> regression. Also, we had no change in the performance/plan after >> re-analyzing all tables. > > You do know that temp tables go into the default temp table space, > just like sorts, right? Not so. This system has no defined temp_tablespace however spillage due to sorting/hashing that exceeds work_mem goes to base/pgsql_tmp which we have symlinked out to a local SSD drive. We do run a few of our other systems with temp_tablespace defined and for these the heap/index files do share same volume as other temp usage. Thx > > Have you used something like iostat to see which volume is getting all the IO? > >> >>> >>> Also increasing work_mem (but don't go crazy, it's per sort, so can >>> multiply fast on a busy server) >> >> >> We are already up at 400MB, and this query was using memory in the low KB >> levels because it is very small (1 - 20 rows of data per temp table, and no >> expensive selects with missing indexes or anything). > > Ahh so it doesn't sound like it's spilling to disk then. Do the logs > say yes or no on that? > > Basically use unix tools to look for where you're thrashing. iotop can > be handy too. -- Jerry Sievers Postgres DBA/Development Consulting e: postgres.consulting@comcast.net p: 312.241.7800 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance