pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alex <cdalxndr@yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15717: Index not used when ordering by left joined table column
Date: Thu, 28 Mar 2019 08:40:56 +0000 (UTC)
Message-ID: <765434487.12847357.1553762456299@mail.yahoo.com> (raw)
In-Reply-To: <11046.1553735962@sss.pgh.pa.us>
References: <15717-e8df3cbc92d5d474@postgresql.org>
	<11046.1553735962@sss.pgh.pa.us>

 Indeed, with an inner join the index is used.Thanks for the assistance.



    On Thursday, March 28, 2019, 3:19:30 AM GMT+2, Tom Lane <tgl@sss.pgh.pa.us> wrote:  
 
 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
  

view thread (3+ messages)

Message-ID: <765434487.12847357.1553762456299@mail.yahoo.com>
Permalink:  ../765434487.12847357.1553762456299@mail.yahoo.com/
Also on:    postgresql.org/message-id/765434487.12847357.1553762456299@mail.yahoo.com

 · 

reply

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: cdalxndr@yahoo.com, tgl@sss.pgh.pa.us
  Subject: Re: BUG #15717: Index not used when ordering by left joined table column
  In-Reply-To: <765434487.12847357.1553762456299@mail.yahoo.com>
  References: <15717-e8df3cbc92d5d474@postgresql.org> <11046.1553735962@sss.pgh.pa.us> <765434487.12847357.1553762456299@mail.yahoo.com>

* 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