{"record":{"id":"d42a5d3bb74458a6","repo":"apache/superset","slug":"sqllab-timeout-error","errorCode":"SQLLAB_TIMEOUT_ERROR","errorMessage":"The query estimation was killed after %(sqllab_timeout)s seconds. It might be too complex, or the database might be under heavy load.","messagePattern":"The query estimation was killed after (.+?) seconds\\. It might be too complex, or the database might be under heavy load\\.","errorType":"http","errorClass":"SupersetErrorException","httpStatus":500,"severity":"error","filePath":"superset/commands/sql_lab/estimate.py","lineNumber":199,"sourceCode":"        # (sql_lab.execute_sql_statements) so cost estimation cannot be used to\n        # probe disallowed functions/tables, bypass the DML guard, or confirm\n        # the existence of rows hidden by row-level security.\n        sql = self._apply_sql_security(sql)\n\n        timeout = app.config[\"SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT\"]\n        timeout_msg = f\"The estimation exceeded the {timeout} seconds timeout.\"\n        try:\n            with utils.timeout(seconds=timeout, error_message=timeout_msg):\n                cost = self._database.db_engine_spec.estimate_query_cost(\n                    self._database,\n                    self._catalog,\n                    self._schema,\n                    sql,\n                    utils.QuerySource.SQL_LAB,\n                )\n        except SupersetTimeoutException as ex:\n            logger.exception(ex)\n            raise SupersetErrorException(\n                SupersetError(\n                    message=__(\n                        \"The query estimation was killed after %(sqllab_timeout)s \"\n                        \"seconds. It might be too complex, or the database might be \"\n                        \"under heavy load.\",\n                        sqllab_timeout=app.config[\"SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT\"],\n                    ),\n                    error_type=SupersetErrorType.SQLLAB_TIMEOUT_ERROR,\n                    level=ErrorLevel.ERROR,\n                ),\n                status=500,\n            ) from ex\n\n        spec = self._database.db_engine_spec\n        query_cost_formatters: dict[str, Any] = app.config[\n            \"QUERY_COST_FORMATTERS_BY_ENGINE\"\n        ]\n        query_cost_formatter = query_cost_formatters.get(","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/sql_lab/estimate.py#L181-L217","documentation":"Raised in EstimateQueryCostCommand.run() (superset/commands/sql_lab/estimate.py:199) when the engine spec's estimate_query_cost call exceeds the timeout enforced by utils.timeout and throws SupersetTimeoutException; it is re-raised as SupersetErrorException with error_type SQLLAB_TIMEOUT_ERROR and HTTP 500. The timeout value comes from the SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT config, and the message interpolates that same value as sqllab_timeout.","triggerScenarios":"Cost estimation against a database engine whose cost-estimate query (usually an EXPLAIN against the target database) takes longer than SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT seconds — very complex SQL, huge partitioned tables, or a slow/overloaded database.","commonSituations":"Default estimate timeout being short while the analytical database is under load; estimators on some engines running expensive plans; network latency to remote databases.","solutions":["Retry when the database is less loaded; a one-off timeout is often transient","Simplify the SQL being estimated (fewer joins/subqueries) so the engine's EXPLAIN completes faster","Ask the operator to raise SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT in superset_config.py if estimates legitimately need longer"],"exampleFix":"# superset_config.py — raise the estimation budget\nSQLLAB_QUERY_COST_ESTIMATE_TIMEOUT = 120  # seconds, was 10","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    cost = EstimateQueryCostCommand(params).run()\nexcept SupersetErrorException as ex:\n    if ex.error.error_type == SupersetErrorType.SQLLAB_TIMEOUT_ERROR:\n        # transient under load: retry with backoff, or skip estimation\n        ","preventionTips":["Estimate cost for simplified versions of very large queries","Know your SQLLAB_QUERY_COST_ESTIMATE_TIMEOUT value; ask the operator to raise it if estimates routinely time out"],"tags":["sql-lab","timeout","query-cost","performance","config"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}