Re: slow information schema with thausand users, seq.scan pg_authid

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: andrew(at)supernews(dot)com, Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: slow information schema with thausand users, seq.scan pg_authid
Date: 2006-02-06 19:10:29
Message-ID: 28422.1139253029@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Andrew - Supernews <andrew+nonews(at)supernews(dot)com> writes:
> On 2006-02-06, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> It already has indexes.

> True, but they're not being used where you'd expect. This seems to be
> something to do with the fact that it's not pg_authid which is being
> accessed, but rather the view pg_roles.

I looked into this and it seems the problem is that the view doesn't
get flattened into the main query because of the has_nullable_targetlist
limitation in prepjointree.c. That's triggered because pg_roles has
'********'::text AS rolpassword
which isn't nullable, meaning it would produce wrong behavior if
referenced above the outer join.

Ultimately, the reason this is a problem is that the planner deals only
in simple Vars while processing joins; it doesn't want to think about
expressions. I'm starting to think that it may be time to fix this,
because I've run into several related restrictions lately, but it seems
like a nontrivial project.

In the meantime, reducing the LEFT JOIN to pg_roles to a JOIN as per
Peter's suggestion seems like the best short-term workaround.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Browne 2006-02-06 21:45:11 Re: [PORTS] Failed install - libgen.so doesn't exist
Previous Message Josh Berkus 2006-02-06 19:03:06 Re: Copy From & Insert UNLESS

Browse pgsql-patches by date

  From Date Subject
Next Message Michael Meskes 2006-02-06 20:33:16 Re: [BUGS] BUG #2171: Differences compiling plpgsql in ecpg and psql
Previous Message Stephen Frost 2006-02-06 18:55:20 Re: [HACKERS] Krb5 & multiple DB connections