Re: Merge Join chooses very slow index scan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jake Magner <jakemagner90(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Merge Join chooses very slow index scan
Date: 2015-03-19 14:58:26
Message-ID: 31348.1426777106@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I wrote:
> [ assorted possible workarounds ]

Actually, an easy fix might be to create a 2-column index on
usagestats(type, tid). I think the planner should be able to
use that to produce sorted output for the mergejoin, and you'd
get the best of both worlds, because the indexscan will stop
immediately when it's exhausted the rows with type = 'vehicle'.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jake Magner 2015-03-19 16:40:49 Re: Merge Join chooses very slow index scan
Previous Message Tom Lane 2015-03-19 14:28:52 Re: Merge Join chooses very slow index scan