Managing Many-to-Many Relationships with PL/pgSQL (6 tags)
SQL gives you plenty of options for handling relationships--you can use joins and database relations, or you can make multiple queries and write complex logic on the client. What are the benefits and drawbacks of each? David Wheeler recently experimented with moving complex relationship logic into PostgreSQL's PL/pgSQL language; the results were stunning.
Batch Updates with PL/pgSQL (5 tags)
Loops are slow, algorithmically speaking. Every time you find yourself looping over data, you have a process that, at best, scales linearly with the number of items to process. SQL gives you options to perform multiple updates at once; David Wheeler demonstrates how to make them work with PL/pgSQL.