Re: View with and without ::text casting performs differently. - Mailing list pgsql-performance

From Tom Lane
Subject Re: View with and without ::text casting performs differently.
Date
Msg-id 1960.1378425018@sss.pgh.pa.us
Whole thread Raw
In response to View with and without ::text casting performs differently.  (Brian Fehrle <brianf@consistentstate.com>)
Responses Re: View with and without ::text casting performs differently.
List pgsql-performance
Brian Fehrle <brianf@consistentstate.com> 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


pgsql-performance by date:

Previous
From: Brian Fehrle
Date:
Subject: Re: View with and without ::text casting performs differently.
Next
From: Ľubomír Varga
Date:
Subject: planner and having clausule