: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
fix(query-performance): cap export scan parallelism at 24 threads (#67841)
Andy Zhao20626f08aa21
diff --git a/posthog/dags/export_query_log_archive_to_s3.py b/posthog/dags/export_query_log_archive_to_s3.pyindex fb9de5d54d96..5b08a3f10e12 100644--- a/posthog/dags/export_query_log_archive_to_s3.py+++ b/posthog/dags/export_query_log_archive_to_s3.py@@ -1,4 +1,5 @@import dagster+import pydanticfrom clickhouse_driver import Clientfrom posthog import settings@@ -99,6 +100,11 @@ ONE_GB = 1024 * 1024 * 1024class QueryLogArchiveExportConfig(dagster.Config):+ max_threads: int = pydantic.Field(+ default=24,+ ge=1,+ description="ClickHouse max_threads for the export scan. Must be ≥ 1 (0 means auto/all-cores in ClickHouse and will re-enable the OOM risk).",+ )s3_prefix: str = "query_log_archive"s3_bucket: str = settings.QUERY_LOG_ARCHIVE_EXPORT_S3_BUCKET@@ -133,7 +139,7 @@ SELECTnormalizeQuery(lc_query__query) AS hogql_shapeFROM {SOURCE_TABLE}WHERE event_date = toDate('{day}') AND is_initial_query-SETTINGS s3_truncate_on_insert = 1+SETTINGS s3_truncate_on_insert = 1, max_threads = {config.max_threads}"""def run(client: Client) -> str: