In this chapter, a number of query optimizations have been discussed. You have learned about the optimizer and about various internal optimizations, such as constant folding, view inlining, joins, and a lot more. All those optimizations contribute to good performance and help to speed things up considerably.
After this introduction to optimizations, Chapter 7, Writing Stored Procedures, will be about stored procedures. You will see the options PostgreSQL has to handle user-defined code.