Re: View performance with implicit cast

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomasz Szypowski <tomasz(dot)szypowski(at)asseco(dot)pl>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: View performance with implicit cast
Date: 2025-01-04 18:37:29
Message-ID: 640397.1736015849@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tomasz Szypowski <tomasz(dot)szypowski(at)asseco(dot)pl> writes:
> I have got an example, in which PostgreSQL could speed up:

The reason why the first version of the view doesn't behave well
is that it's not optimized into an "append relation", because
is_simple_union_all() doesn't think that's safe:

/*
* is_simple_union_all
* Check a subquery to see if it's a simple UNION ALL.
*
* We require all the setops to be UNION ALL (no mixing) and there can't be
* any datatype coercions involved, ie, all the leaf queries must emit the
* same datatypes.
*/

Perhaps this could be improved, but it's a lot easier just to add
the cast yourself.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Szypowski 2025-01-05 22:45:14 RE: View performance with implicit cast
Previous Message Tomasz Szypowski 2025-01-02 20:02:05 View performance with implicit cast