Re: Slow PostgreSQL 10.6 query

2019-10-07 Thread Behrang Saeedzadeh
Thanks for the tip! Regards, Behrang (sent from my mobile) On Mon, Oct 7, 2019, 07:37 Tomas Vondra wrote: > On Tue, Oct 01, 2019 at 11:42:33PM +1000, Behrang Saeedzadeh wrote: > >Thanks. That eliminated the bottleneck! > > > >Any ideas why adding ORDER BY to the subquery also changes the plan i

Re: Slow PostgreSQL 10.6 query

2019-10-06 Thread Tomas Vondra
On Tue, Oct 01, 2019 at 11:42:33PM +1000, Behrang Saeedzadeh wrote: Thanks. That eliminated the bottleneck! Any ideas why adding ORDER BY to the subquery also changes the plan in a way that eliminates the bottleneck? IIRC the ORDER BY clause makes it impossible to "collapse" the subquery into

Re: Slow PostgreSQL 10.6 query

2019-10-01 Thread Behrang Saeedzadeh
Thanks. That eliminated the bottleneck! Any ideas why adding ORDER BY to the subquery also changes the plan in a way that eliminates the bottleneck? Best regards, Behrang Saeedzadeh blog.behrang.org On Tue, 1 Oct 2019 at 23:27, Tom Lane wrote: > Behrang Saeedzadeh writes: > > On my machine,

Re: Slow PostgreSQL 10.6 query

2019-10-01 Thread Tom Lane
Behrang Saeedzadeh writes: > On my machine, this query that is generated by Hibernate runs in about 57 > ms on MySQL 8 but it takes more than 1 second to run on PostgreSQL: > SELECT bills.id AS bill_id, >bills.bill_date AS bill_date, >bills.bill_number