<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/all-your-gucs-in-a-row-from-collapse-limit-r62ismyyi" -->

---
title: All Your GUCs in a Row: from_collapse_limit | daily.dev
description: PostgreSQL's `from_collapse_limit` GUC controls whether subqueries in FROM clauses get flattened into the outer query for joint planning. The default value of...
canonical: https://daily.dev/posts/all-your-gucs-in-a-row-from-collapse-limit-r62ismyyi
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: All Your GUCs in a Row: from_collapse_limit | daily.dev
og:description: PostgreSQL's `from_collapse_limit` GUC controls whether subqueries in FROM clauses get flattened into the outer query for joint planning. The default value of...
og:url: https://daily.dev/posts/all-your-gucs-in-a-row-from-collapse-limit-r62ismyyi
og:image: https://api.daily.dev/og/posts/r62IsMYYI.png
og:image:alt: All Your GUCs in a Row: from_collapse_limit
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# All Your GUCs in a Row: from_collapse_limit

**[Planet PostgreSQL](https://daily.dev/sources/planet-postgresql)** · 4 min read · 0 upvotes · 0 comments

## Summary

PostgreSQL's `from_collapse_limit` GUC controls whether subqueries in FROM clauses get flattened into the outer query for joint planning. The default value of 8 means the planner merges subqueries only when the resulting FROM list stays at or below 8 items. Flattening allows the planner to consider cross-subquery join orders, often producing better plans, but the search space grows factorially with more relations. Subqueries with aggregation, DISTINCT, LIMIT, OFFSET, window functions, or set operations are never flattened regardless of this setting — which is the basis of the OFFSET 0 fence trick. Raising the limit above 12 risks triggering GEQO (genetic query optimizer), which samples rather than exhaustively searches join orders and can produce worse plans. If you raise `from_collapse_limit`, also raise `geqo_threshold` above it. Best practice: keep it at 8 in postgresql.conf and experiment per-session using the user context.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://postgr.es/p/9qj>

## Similar posts on daily.dev

- [All Your GUCs in a Row: join\_collapse\_limit](https://daily.dev/posts/all-your-gucs-in-a-row-join-collapse-limit-rykvggydx) · Planet PostgreSQL · 1 upvotes · 1 comments
- [All Your GUCs in a Row: The geqo Family](https://daily.dev/posts/all-your-gucs-in-a-row-the-geqo-family-jnt577kaa) · Planet PostgreSQL · 0 upvotes · 0 comments
- [All Your GUCs in a Row: gin\_fuzzy\_search\_limit](https://daily.dev/posts/all-your-gucs-in-a-row-gin-fuzzy-search-limit-jw9vfi5nr) · Planet PostgreSQL · 1 upvotes · 2 comments
- [All Your GUCs in a Row: constraint\_exclusion](https://daily.dev/posts/all-your-gucs-in-a-row-constraint-exclusion-thbwdhnen) · Planet PostgreSQL · 13 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/all-your-gucs-in-a-row-from-collapse-limit-r62ismyyi)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"All Your GUCs in a Row: from_collapse_limit","url":"https://daily.dev/posts/all-your-gucs-in-a-row-from-collapse-limit-r62ismyyi","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/all-your-gucs-in-a-row-from-collapse-limit-r62ismyyi"},"datePublished":"2026-07-23T02:34:47.215Z","dateModified":"2026-07-23T02:35:07.849Z","description":"PostgreSQL's `from_collapse_limit` GUC controls whether subqueries in FROM clauses get flattened into the outer query for joint planning. The default value of...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/179f0e16ac9f0a070d6f2fa9d3c06ebf?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/179f0e16ac9f0a070d6f2fa9d3c06ebf?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet PostgreSQL","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet PostgreSQL","logo":"https://media.daily.dev/image/upload/logos/placeholder.jpg","url":"https://daily.dev/sources/planet-postgresql"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/all-your-gucs-in-a-row-from-collapse-limit-r62ismyyi","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"postgresql","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet PostgreSQL","item":"https://daily.dev/sources/planet-postgresql"},{"@type":"ListItem","position":3,"name":"All Your GUCs in a Row: from_collapse_limit"}]}
```

