Let's imagine simple situation – you have table of objects (each with id), and you want objects 3, 71, 5 and 16. And in that order!
How to do it?
Continue reading How to order by some random – query defined – values?
Let's imagine simple situation – you have table of objects (each with id), and you want objects 3, 71, 5 and 16. And in that order!
How to do it?
Continue reading How to order by some random – query defined – values?
I got asked this: having this table:
# select * from a order by d; t | d ---+---- O | 1 O | 2 O | 3 M | 4 M | 5 M | 6 M | 7 O | 8 O | 9 O | 10 I | 11 I | 12 I | 13 (13 rows)
Is it possible to add “rank" column, that will increment whenever t changed?
One database that I am monitoring uses a lot of stored procedures. Some of them are fast, some of them are not so fast. I thought – is there a sensible way to diagnose which part of stored procedure take the most time?
I mean – I could just put the logic into application, and then every query would have it's own timing in Pg logs, but this is not practical. And I also believe that using stored procedures/functions is way better than using plain SQL due to a number of reasons.
So, I'm back to question – how to check which part of function takes most of the time?
On 12th of February Tom Lane committed patch by Hitoshi Harada:
Log Message: ----------- Extend the set of frame options supported for window functions. This patch allows the frame to start from CURRENT ROW (in either RANGE or ROWS mode), and it also adds support for ROWS n PRECEDING and ROWS n FOLLOWING start and end points. (RANGE value PRECEDING/FOLLOWING isn't there yet --- the grammar works, but that's all.) Hitoshi Harada, reviewed by Pavel Stehule
Continue reading Waiting for 9.0 – extended frames for window functions
A long overdue post about new functionality. At this moment it is no longer such new, as it was committed on 28th of December (yes, I know, I should have written it earlier, Sorry).
On this day Tom Lane committed patch by Hitoshi Harada which adds support for so called window functions:
Support window functions a la SQL:2008. Hitoshi Harada, with some kibitzing from Heikki and Tom.
Yesterday Tom Lane committed enormous patch, which had commit log:
Support window functions a la SQL:2008. Hitoshi Harada, with some kibitzing from Heikki and Tom.
… and that would be all. I will write more about it, its use cases, and some detailed examples but now I'm on vacation, and will stay here for some time. You can expect to get the post mid next-week.