3 ms·
Author here. I didn't know about first_value. Thanks for the tip! I'll play with this later today and see if it performs any better. In any case, it makes the
by drob 12y ago
Author here. I didn't know about first_value. Thanks for the tip!
I'll play with this later today and see if it performs any better. In any case, it makes the query easier to read, so we'll probably use this unless it somehow makes the function slower.
Thanks again!
- drob 11y agoProfiled this. Using first_value instead of the additional sub-select made this perform slower at a factor of about 2x for arrays of 1M events. Interesting, and very surprising! I'm going to dig around and see if I can't figure out why this is the case. I would have guessed there would be a minor performance improvement, because the first_value approach effectively allows PostgreSQL to discard the data sooner, instead of materializing it in an additional subquery.
- dbenhur 11y agoWow... I am surprised. If you gather some useful data please send it on to postgresql-dev and.or postgresql-performance so some core devs can fix it in subsequent releases.