pg12 - partition by column that might have null values

2019-10-01 Thread Mariel Cherkassky
Hey, In PG12 I'm trying to create partitions by range on a date column that might be null (indicates it is the most recent version of the object). My PK has to include the partition column, therefore I'm getting an error that I cant create a primary key with the specific column because it has null

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