Speed up complicated analytics queries using common table expressions
The CTE is a feature of PostgreSQL aimed at improving readability, but in some cases it can help the performance by eliminating analytic passes over the data. In case of the top50 IP addresses, this can help a lot, moving back to acceptable performance levels.
Author: Radko Krkoš krkos@cesnet.cz