Query Plan Hints
As we saw earlier, SQL uses a declarative model. This model has an intentional separation between the queries that clients provide and the execution plan that PostgreSQL chooses.
While programmers can “influence” execution plans to an extent via their query or schema designs and indexes, they cannot directly “control” plans that PostgreSQL chooses.
Right? Well, that’s true, but there’s another concept that’s sort of a middle ground that can be used to control portions of a plan. The concept is called hinting or “query plan hinting.” With query plan hints, we can control part of the query plan using hints that are passed to queries as text comments.
Query plan hinting is not available in core PostgreSQL but can be added using ...
Get High Performance PostgreSQL for Rails now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.