:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore: Postgres: removed chunk cap from partitioned tables sync (#58337)
Daniel RC96babbee113b
diff --git a/posthog/temporal/data_imports/sources/postgres/partitioned_tables.py b/posthog/temporal/data_imports/sources/postgres/partitioned_tables.pyindex 8d2d0b64762a..bcf97832667c 100644--- a/posthog/temporal/data_imports/sources/postgres/partitioned_tables.py+++ b/posthog/temporal/data_imports/sources/postgres/partitioned_tables.py@@ -21,11 +21,6 @@ from posthog.temporal.data_imports.pipelines.pipeline.utils import (from products.data_warehouse.backend.types import IncrementalFieldType, PartitionSettings-# Max rows per FETCH when reading a partitioned parent table. A partitioned-# parent scan dispatches across every child partition; a large chunk size can-# blow past the source's statement_timeout even when per-row payload is small.-PARTITIONED_TABLE_MAX_CHUNK_SIZE = 30_000-# Retry budgets for iterate_date_windows. Counters reset on every successful# window. Exhausting QueryCanceled surfaces QueryTimeoutException; exhausting# SerializationFailure re-raises the original error so the caller can decide@@ -637,7 +632,6 @@ def is_supported_incremental_type_for_window(field_type: Optional[IncrementalFie__all__ = [- "PARTITIONED_TABLE_MAX_CHUNK_SIZE","WINDOW_MAX_QUERY_CANCELED_RETRIES","WINDOW_MAX_SERIALIZATION_RETRIES","ChildPartition",diff --git a/posthog/temporal/data_imports/sources/postgres/postgres.py b/posthog/temporal/data_imports/sources/postgres/postgres.pyindex a13c8c7c90df..a243ddfebd2f 100644--- a/posthog/temporal/data_imports/sources/postgres/postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/postgres.py@@ -39,7 +39,6 @@ from posthog.temporal.data_imports.pipelines.pipeline.utils import ()from posthog.temporal.data_imports.sources.common.sql import Column, Tablefrom posthog.temporal.data_imports.sources.postgres.partitioned_tables import (- PARTITIONED_TABLE_MAX_CHUNK_SIZE,build_partition_query,get_estimated_row_count_for_partitioned_table as _get_estimated_row_count_for_partitioned_table,get_partition_settings_for_partitioned_table as _get_partition_settings_for_partitioned_table,@@ -1562,15 +1561,7 @@ def postgres_source(logger.debug(f"Using chunk_size_override: {chunk_size_override}")else:chunk_size = _get_table_chunk_size(cursor, inner_query_with_limit, logger)- # Cap chunk size for partitioned tables. Server-cursor FETCH- # on a partitioned parent scans across all child partitions,- # so a large chunk can exceed statement_timeout even when- # per-row size is small.- if is_partitioned and chunk_size > PARTITIONED_TABLE_MAX_CHUNK_SIZE:- logger.debug(- f"Capping chunk_size from {chunk_size} to {PARTITIONED_TABLE_MAX_CHUNK_SIZE} for partitioned table"- )- chunk_size = PARTITIONED_TABLE_MAX_CHUNK_SIZE+logger.debug("Getting rows to sync...")# For partitioned tables without an incremental cursor (initial# sync, re-sync, or non-incremental), use pg_class.reltuplesdiff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.pyindex b15c85e28c73..114cefa85ca0 100644--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py@@ -13,6 +13,7 @@ import pyarrow as paimport structlogfrom psycopg import sql+import posthog.temporal.data_imports.sources.postgres.partitioned_tables as partitioned_tables_pkgfrom posthog.temporal.data_imports.pipelines.pipeline.utils import (DEFAULT_NUMERIC_SCALE,MAX_NUMERIC_SCALE,@@ -588,6 +589,14 @@ class TestIsPartitionedTable:assert _is_partitioned_table(cast(Any, dj_cursor), "public", table_name) is expected+class TestPartitionedTableChunkSizing:+ """Incremental reads use per-child partition queries; no parent FETCH chunk cap."""++ def test_no_partitioned_fetch_cap_exported(self) -> None:+ assert not hasattr(partitioned_tables_pkg, "PARTITIONED_TABLE_MAX_CHUNK_SIZE")+ assert "PARTITIONED_TABLE_MAX_CHUNK_SIZE" not in partitioned_tables_pkg.__all__++class TestGetEstimatedRowCountForPartitionedTable:@pytest.mark.django_dbdef test_returns_estimate_for_partitioned_table(self):