6. Performant SQL
Overview
By the end of this chapter, we will be able to optimize database use to allow queries to be executed with fewer resources. First, we will look at how a database engine performs basic queries by developing our understanding of the sequential scan. Next, we will look at optimizing SELECT
queries by creating indexes on our tables that improve performance. We will also examine the benefits of using joins in place of other functionality. We will explore advanced functionality by creating custom functions for special computations and examine how to apply custom constraints on our database by leveraging triggers. Finally, we will learn about tools and techniques for terminating inefficient queries that are consuming our database resources.