From: Tom Lane <tgl@sss.pgh.pa.us>
To: cdalxndr@yahoo.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15717: Index not used when ordering by left joined table column
Date: Wed, 27 Mar 2019 21:19:22 -0400
Message-ID: <11046.1553735962@sss.pgh.pa.us> (raw)
In-Reply-To: <15717-e8df3cbc92d5d474@postgresql.org>
References: <15717-e8df3cbc92d5d474@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> The following query runs slow, as it seq scans tables, without using any
> index:
> select
> wp.id as id
> from
> web_page wp
> left join web_url_path url on wp.id=url.page
> order by
> url.priority asc
> limit 1
> I was expecting the "priority" column index would be used to retrieve first
> url then do a reverse join to get the corresponding page, and continue if no
> page is found.
It would probably do that if you used a plain join, or a right join.
But a nestloop plan cannot be driven from the inside of an outer join,
and that's the case this query presents.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, cdalxndr@yahoo.com
Subject: Re: BUG #15717: Index not used when ordering by left joined table column
In-Reply-To: <11046.1553735962@sss.pgh.pa.us>
References: <15717-e8df3cbc92d5d474@postgresql.org> <11046.1553735962@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox