Re: Searching union views not using indices

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michal Taborsky <michal(dot)taborsky(at)mall(dot)cz>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Searching union views not using indices
Date: 2005-11-04 17:53:07
Message-ID: 15833.1131126787@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Michal Taborsky <michal(dot)taborsky(at)mall(dot)cz> writes:
> OK. Mystery (sort of) solved. After you told me it works for you I had
> to assume the problem was somewhere else. And, indeed, it was, though
> it's not too obvious.

> The two attributes are actually not of tybe bigint, but of type
> "crm_object_id", which is created as follows:

> CREATE DOMAIN "public"."crm_object_id" AS
> bigint NULL;

Ah. The problem is that the UNION's output column is bigint, and the
type discrepancy (bigint above, domain below) discourages the planner
from pushing down the WHERE condition.

There's a related complaint here:
http://archives.postgresql.org/pgsql-bugs/2005-10/msg00227.php

If we were to change things so that the result of the UNION were still
the domain, not plain bigint, then your example would be optimized the
way you want. I'm unsure about what other side-effects that would have
though.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2005-11-04 17:56:02 Re: insert performance for win32
Previous Message Tom Lane 2005-11-04 16:33:52 Re: insert performance for win32