Re: Very specialised query - Mailing list pgsql-performance

From Віталій Тимчишин
Subject Re: Very specialised query
Date
Msg-id 331e40660903311411k532df0e3jeeffdb184adba9e6@mail.gmail.com
Whole thread Raw
In response to Re: Very specialised query  (Matthew Wakeling <matthew@flymine.org>)
Responses Re: Very specialised query
List pgsql-performance

The outer nested join has the VALUES as the main loop, and the complicated join as the leaf. So, the complicated overlap-finding join gets run twice.

That's weird. What do you have as statistics target? Planner is incorrect few orders of magnitude, so increasing it may help.
BTW: One of constraints is redundant l1.start <= l2.start implies l1.start <= l2.end, so latter can be removed as for me.
 


Oh, there's also the great big sort and unique, but I think I can get rid of that.

As far as I can see, duplicates will occur if and only if l1.start == l2.start && l1.end == l2.end.
That can be easily filtered by adding "where n=1 or l1.start != l2.start or l1.end != l2.end" to outer select.

pgsql-performance by date:

Previous
From: Matthew Wakeling
Date:
Subject: Re: Very specialised query
Next
From: "Kevin Grittner"
Date:
Subject: Re: Strange behavior: pgbench and new Linux kernels