Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bBNCC-0004lm-54 for pgsql-performance@arkaria.postgresql.org; Fri, 10 Jun 2016 14:14:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bBNCB-0001rG-NA for pgsql-performance@arkaria.postgresql.org; Fri, 10 Jun 2016 14:13:59 +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 1bBNC4-0001jG-10 for pgsql-performance@postgresql.org; Fri, 10 Jun 2016 14:13:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bBNC0-0004ZT-QL for pgsql-performance@postgresql.org; Fri, 10 Jun 2016 14:13:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u5AEDj5h022657; Fri, 10 Jun 2016 10:13:45 -0400 From: Tom Lane To: Rowan Seymour cc: pgsql-performance@postgresql.org Subject: Re: Many-to-many performance problem In-reply-to: References: Comments: In-reply-to Rowan Seymour message dated "Fri, 10 Jun 2016 15:04:01 +0200" Date: Fri, 10 Jun 2016 10:13:45 -0400 Message-ID: <22656.1465568025@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) 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 Rowan Seymour writes: > Most of time, this query performs like https://explain.depesz.com/s/ksOC > (~15ms). It's no longer using the using the msgs_inbox index, but it's > plenty fast. However, sometimes it performs like > https://explain.depesz.com/s/81c (67000ms) > And if you run it again, it'll be fast again. It looks like everything is fine as long as all the data the query needs is already in PG's shared buffers. As soon as it has to go to disk, you're hurting, because disk reads seem to be taking ~10ms on average. > Server is an Amazon RDS instance with default settings and Postgres 9.3.10, And I think you just explained your problem. Did you spring for adequate guaranteed IOPS on this instance? If not, you need to, or else live with erratic performance. If you did, you have a beef to raise with AWS that you're not getting the performance you paid for. You might be able to ameliorate matters by raising shared_buffers, but unless your database isn't growing that approach has limited future. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance