Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQHSJ-0007Sy-A4 for pgsql-admin@arkaria.postgresql.org; Sun, 08 Jan 2017 17:40:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cQHSI-0004H4-TA for pgsql-admin@arkaria.postgresql.org; Sun, 08 Jan 2017 17:40:30 +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 1cQHSI-0004Gy-G7 for pgsql-admin@postgresql.org; Sun, 08 Jan 2017 17:40:30 +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 1cQHSF-00019X-Pg for pgsql-admin@postgresql.org; Sun, 08 Jan 2017 17:40:29 +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 v08HeQ2A031825; Sun, 8 Jan 2017 12:40:26 -0500 From: Tom Lane To: David L cc: pgsql-admin@postgresql.org Subject: Re: Using Views as Tables In-reply-to: References: Comments: In-reply-to David L message dated "Sun, 08 Jan 2017 16:30:48 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31823.1483897226.1@sss.pgh.pa.us> Date: Sun, 08 Jan 2017 12:40:26 -0500 Message-ID: <31824.1483897226@sss.pgh.pa.us> X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org David L writes: > This is apparently leading to some confusing results when people are > querying these views with inconsistent query times. Sometimes queries are > taking two or three seconds, other times 20 or 30 milliseconds, the latter > being what we'd expect. Naturally, the fact that these are views they are > querying is the first thing I'm questioning here and I've never seen query > times of seconds using the table directly on the limited experiments I've > done. I think you're barking up the wrong tree. A view as simple as "select * from something" should get flattened out of the plan entirely. You should check that with EXPLAIN, but I'd expect that you get identical plans from querying either the view or the underlying table. What seems more plausible is that the inconsistent query times have to do with locking, or with I/O stalls due to table data sometimes not being in memory. Either of these might be rare enough that you simply didn't see it in "limited experiments" with direct queries, but they'd apply to that case just as well. regards, tom lane -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin