Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VHjJj-0001aJ-Dc for pgsql-performance@arkaria.postgresql.org; Thu, 05 Sep 2013 23:50:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VHjJi-0008KY-IL for pgsql-performance@arkaria.postgresql.org; Thu, 05 Sep 2013 23:50:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VHjJh-0008KS-QP for pgsql-performance@postgresql.org; Thu, 05 Sep 2013 23:50:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VHjJc-0006sC-UN for pgsql-performance@postgresql.org; Thu, 05 Sep 2013 23:50:25 +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 r85NoIYm001961; Thu, 5 Sep 2013 19:50:18 -0400 From: Tom Lane To: Brian Fehrle cc: pgsql-performance@postgresql.org Subject: Re: View with and without ::text casting performs differently. In-reply-to: <5229097C.4070401@consistentstate.com> References: <5229097C.4070401@consistentstate.com> Comments: In-reply-to Brian Fehrle message dated "Thu, 05 Sep 2013 16:45:16 -0600" Date: Thu, 05 Sep 2013 19:50:18 -0400 Message-ID: <1960.1378425018@sss.pgh.pa.us> X-Pg-Spam-Score: -4.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 Brian Fehrle writes: > I have a view, that when created with our create statement works > wonderfully, a query on the view with a standard where clause that > narrows the result to a single row performs in under a single ms. > However, when we export this view and re-import it (dump and restore of > the database, which happens often), the exported version of the view has > been modified by Postgres to include various typecasting of some columns > to text. This is normal (varchar doesn't actually have any operations of its own). > All columns that it typecasts to text are varchar(20), so there is > nothing wrong in what it's doing there. However, with the view > definition including the ::text casting, the query planner changes and > it goes into a nested loop, taking a query from <1ms to over ten minutes. I rather doubt that the now-explicit-instead-of-implicit casts have much to do with that. It seems more likely that you forgot to re-ANALYZE in the new database, or there are some different planner settings, or something along that line. 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