In this recipe, we will be discussing CTE (Common Table Expression) scans.
CTEs are the named inline queries, which we define using the
WITH clause, and they can be used multiple times in the same query. We can also implement recursive/DML queries using CTEs. CTE improves the query readability when compared with inline sub queries. CTE also provide the
RECURSIVE option, which takes the usage of CTE to another level. Using recursive CTE statements, we can build hierarchical SQL queries where the SQL execution refers to its own results for further processing.
benchmarksql=# EXPLAIN WITH costly_products AS ( SELECT i_name FROM bmsql_item ...