Postgresql - Lag and Windowing Function
Lag came in handy again.
Creator of Interesting Things
Lag came in handy again.
“Should any American soldier be so base and infamous as to injure any [prisoner]. . . I do most earnestly enjoin you to bring him to such severe and exemplary punishment as the enormity of the crime may require. Should it extend to death itself, it will not be disproportional to its guilt at such a time and in such a cause… for by such conduct they bring shame, disgrace and ruin to themselves and their country.” – George Washington
In a standard smallish Postgresql installation its actually fairly straightforward to figure out what indexes to create to eliminate sequential scans and improve your performance. But in a larger system where there are thousands of different queries, perhaps written by dozens of different engineers, the problem of addressing performance issues gets a bit more difficult. However, the same techniques can be used on both systems. I’ll describe what I use and perhaps it will be useful for someone else.
Some days you just want to know who is connecting up to your database. The following SQL works for 9.3 Postgresql.
Frankly I don’t think they necessarily have brisket in Morocco. Never been. and Moroccan-style is probably a stretch too but I had to call it something. Ah well. It was quite yummy and I got asked for recipe. Ingredients hmmm…let’s see.