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 ...

Today another great patch, committed by Tom Lane. This patch was written by Martin Pihlak (with some edits by Tom).