Re: Index not used in certain nested views but not in others

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Markus Demleitner <msdemlei(at)ari(dot)uni-heidelberg(dot)de>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Index not used in certain nested views but not in others
Date: 2025-05-13 14:12:46
Message-ID: 3847.1747145566@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Markus Demleitner <msdemlei(at)ari(dot)uni-heidelberg(dot)de> writes:
> You see, when creating the "big", 30-tables view, I do cast all
> columns to common types in the view statement that actually make up
> the view. The original SQL fragments look like this:

> SELECT
> CAST(ssa_dstype AS text) AS dataproduct_type,
> CAST(NULL AS text) AS dataproduct_subtype,
> CAST(2 AS smallint) AS calib_level,
> ...

> and have a common source, so I'd believe by the time the things end
> up in the view, they should type-align even though their source
> tables do not.

Oh, well, that's your problem. The source tables' column types
need to match. Otherwise the UNIONs don't get flattened and you
don't get indexscans.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Markus Demleitner 2025-05-13 14:48:11 Re: Index not used in certain nested views but not in others
Previous Message Magnus Hagander 2025-05-13 14:06:52 Re: deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main 15