Skip to main content
4 events
when toggle format what by license comment
May 17, 2019 at 7:27 comment added Konstantin Suvorov ...When I changed inner join to subquery and used e.event_time > (subquery...) condition, I saw significant improvements and postgresql started to select a dozen of records from most recent partition and a couple of rows from each partition.
May 17, 2019 at 7:23 comment added Konstantin Suvorov Thank you. Although it is not the answer I was hoping for (like simple switch or something). But I managed to optimize the query while creating MCVE for EXPLAIN. There are a lot of distinct devices with event reports being created for random ones and very seldom, hence no cache. There was device table inner joined by device_id and e.event_time > d.created_time condition to eliminate older devices (because IDs can be reused for different physical devices). For some reason query planer have been selecting all device's events from every partition...
May 17, 2019 at 7:05 vote accept Konstantin Suvorov
May 8, 2019 at 14:35 history answered jjanes CC BY-SA 4.0