- Common Table Expressions (CTEs) allow for temporary results to be stored and reused within the same SQL statement, similar to derived tables or views.
- CTEs can be non-recursive or recursive. Non-recursive CTEs are optimized by merging into joins or pushing conditions down, while recursive CTEs compute results through iterative steps until a fixed point is reached.
- The document discusses optimizations for non-recursive CTEs in MariaDB and provides examples of using CTEs for common queries involving things like hierarchical or network data.