기본적으로(hash_join_execution=multi_pass) 해시 조인의 빌드 측 입력이 너무 커서 메모리에 맞지 않으면 빌드 측이 여러 배치로 분할되어 프로브 측을 여러 번 스캔할 수 있습니다. 새로운 모드(hash_join_execution=one_pass)를 사용하면 해시 조인이 빌드 측 입력이 메모리에 맞지 않을 경우 디스크로 보내고 항상 프로브 측을 한 번만 스캔합니다.
탐색에 사용되는 키 수 선택이 개선되었습니다.
버전 3: 2021년 8월 1일
새 JOIN METHOD 쿼리 힌트 값을 사용하여 사용 설정된 새 조인 알고리즘인 병합 조인을 사용 설정합니다.
조인을 통한 서브 쿼리나 구조체 생성을 포함할 수 있는 더 많은 계산을 푸시합니다. 이렇게 하면 분산 방식으로 더 많은 계산 수행 및 푸시된 계산에 의존하는 더 많은 작업 푸시다운 등과 같은 몇 가지 방법으로 쿼리 성능을 향상시킬 수 있습니다. 예를 들어 쿼리에는 제한이 있으며 정렬 순서는 이러한 계산에 따라 달라지므로 조인을 통해 제한을 푸시할 수도 있습니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-05(UTC)"],[],[],null,["# Spanner query optimizer versions\n\nThis page describes and provides a history of the various Spanner query\noptimizer versions. The current default version is 7.\nTo learn more about the query optimizer, see [About query optimizer](/spanner/docs/query-optimizer/overview).\n\nSpanner rolls out query optimizer updates as new query\noptimizer versions. By default, each database starts using the latest version of\nthe optimizer no sooner than 30 days after that version has been released.\n\nIf you're using a GoogleSQL-dialect database, you can manage the query optimizer version\nthat your queries use. Before committing to the latest version, you can compare\nquery performance profiles between earlier versions and the latest version. To\nlearn more, see [Manage the query optimizer](/spanner/docs/query-optimizer/manage-query-optimizer).\n\nQuery optimizer version history\n-------------------------------\n\nThe following is a summary of the updates made to the query optimizer in each\nrelease.\n\n\u003cbr /\u003e\n\n### Version 8: October 28th, 2024 (latest)\n\n- `WITH` clauses are considered when making cost-based plan choices.\n\n- Improved performance of distributed cross apply and indexed lookup queries.\n\n- Improved `JOIN` reordering.\n\n- Improved performance of queries with large `IN (...)` clauses.\n\n- Improved `GROUP BY` performance in certain cases.\n\n- Other improvements including more efficient handling of queries with `LIMIT`,\n foreign keys, and index selection.\n\n### Version 7: May 22nd, 2024 (default)\n\n- Added support for cost-based selection of index union plans.\n\n- Added support for the smart selection of seek versus scan plans based on\n statistics for queries that don't have seekable predicates for all key parts.\n\n- Added support for cost-based selection of hash joins.\n\n### Version 6: September 11th, 2023\n\n- Improved limit pushing and predicate pushing through full outer joins.\n\n- Improved cardinality estimation and cost model.\n\n- Enabled cost-based optimization for DML queries.\n\n### Version 5: July 15th, 2022\n\n- Improved cost model for index selection, distribution management, sort\n placement and `GROUP BY` selection.\n\n- Added support for cost-based join algorithm selection that chooses between\n hash and apply join. Merge join still requires using a query hint.\n\n- Added support for cost-based join commutativity.\n\n### Version 4: March 1st, 2022\n\n- Improvements to secondary index selection.\n\n - Improved secondary index usage under a join between interleaved tables.\n - Improved covering secondary index usage.\n - Improved index selection when optimizer statistics are outdated.\n - Prefer secondary indexes with predicates on leading indexed columns even if the optimizer statistics are not available or report the base table is small.\n- Introduces single pass hash join, enabled by the new hint\n `hash_join_execution`.\n\n Join Hint: \n\n ### GoogleSQL\n\n SELECT ...\n FROM (...)\n JOIN@{join_method=hash_join, hash_join_execution=one_pass} (...)\n\n ### PostgreSQL\n\n SELECT ...\n FROM (...)\n JOIN/*@ join_method=hash_join, hash_join_execution=one_pass */ (...)\n\n The new mode is beneficial when the [build side input of the hash join](/spanner/docs/query-execution-operators#hash-join)\n is large. One pass hash join is expected to have better performance when you\n observe the following in the [query execution profile](/spanner/docs/tune-query-with-visualizer):\n - The number of executions on the right child of the hash join is larger than the number of executions on the hash join operator.\n - The latency on the right child of the hash join operator is also high.\n\n By default (`hash_join_execution=multi_pass`), if the build side input of\n the hash join is too large to fit in memory, the build side is split into\n multiple batches and we might scan the probe side multiple times. With the\n new mode (`hash_join_execution=one_pass`), a hash join will spill to disk if\n its build side input cannot fit in memory and will always scan the probe\n side only once.\n- An improvement in selecting how many keys are used for seeking.\n\n### Version 3: August 1st, 2021\n\n- Adds a new join algorithm, merge join, enabled using a new [JOIN METHOD](/spanner/docs/reference/standard-sql/query-syntax#join-methods)\n query hint value.\n\n Statement hint: \n\n ### GoogleSQL\n\n @{join_method=merge_join}\n SELECT ...\n\n ### PostgreSQL\n\n /*@ join_method=merge_join */\n SELECT ...\n\n Join hint: \n\n ### GoogleSQL\n\n SELECT ...\n FROM (...)\n JOIN@{join_method=merge_join} (...)\n\n ### PostgreSQL\n\n SELECT ...\n FROM (...)\n JOIN/*@ join_method=merge_join */ (...)\n\n- Adds a new join algorithm, push broadcast hash join, enabled using a new\n [JOIN METHOD](/spanner/docs/reference/standard-sql/query-syntax#join-methods) query hint value.\n\n Join hint: \n\n ### GoogleSQL\n\n SELECT ...\n FROM (...)\n JOIN@{join_method=push_broadcast_hash_join} (...)\n\n ### PostgreSQL\n\n SELECT ...\n FROM (...)\n JOIN/*@ join_method=push_broadcast_hash_join} */ (...)\n\n- Introduces the [distributed merge union](/spanner/docs/query-execution-operators#distributed-merge-union)\n operator, which is enabled by default when applicable. This operation\n improves the performance of queries.\n\n- A small improvement to the performance of a scan under a `GROUP BY` when\n there is no MAX or MIN aggregate (or HAVING MAX/MAX) in the SELECT list.\n Prior to this change, Spanner loaded the extra non-grouped\n column even if it was not required by the query.\n\n For example, consider the following table: \n\n ### GoogleSQL\n\n CREATE TABLE myTable(\n a INT64,\n b INT64,\n c INT64,\n d INT64)\n PRIMARY KEY (a, b, c);\n\n ### PostgreSQL\n\n CREATE TABLE myTable(\n a bigint,\n b bigint,\n c bigint,\n d bigint,\n PRIMARY KEY(a, b, c)\n );\n\n Prior to this change, the following query would have loaded column `c` even\n though it is not required by the query. \n\n SELECT a, b\n FROM myTable\n GROUP BY a, b\n\n- Improves the performance of some queries with `LIMIT` when there is a\n cross apply operator introduced by joins and the query asks for sorted\n results with LIMIT. After this change, the optimizer applies the sorting\n with the limit on the input side of cross apply first.\n\n Example: \n\n ### GoogleSQL\n\n SELECT a2.*\n FROM Albums@{FORCE_INDEX=_BASE_TABLE} a1\n JOIN Albums@{FORCE_INDEX=_BASE_TABLE} a2 USING(SingerId)\n ORDER BY a1.AlbumId\n LIMIT 2;\n\n ### PostgreSQL\n\n SELECT a2.*\n FROM albums/*@ force_index=_base_table */ a1\n JOIN albums/*@ force_index=_base_table */ a2 USING(singerid)\n ORDER BY a1.albumid\n LIMIT 2;\n\n- Improves query performance by pushing more computations through `JOIN`.\n\n Pushes more computations which may include a subquery or struct construction\n through join. That improves the query performance in a few ways such as:\n More computations can be done in a distributed fashion and more operations\n that depend on the pushed computations can be pushed down as well. For\n example, the query has a limit and the sort order depends on those\n computations, then the limit can be pushed through join as well.\n\n Example: \n\n SELECT\n t.ConcertDate,\n (\n SELECT COUNT(*) FROM UNNEST(t.TicketPrices) p WHERE p \u003e 10\n ) AS expensive_tickets,\n u.VenueName\n FROM Concerts t\n JOIN Venues u ON t.VenueId = u.VenueId\n ORDER BY expensive_tickets\n LIMIT 2;\n\n\u003cbr /\u003e\n\n### Version 2: March 1st, 2020\n\n- Adds optimizations in index selection.\n- Improves the performance of `REGEXP_CONTAINS` and `LIKE` predicates under certain circumstances.\n- Improves the performance of a scan under a `GROUP BY` in certain situations.\n\n\u003cbr /\u003e\n\n### Version 1: June 18th, 2019\n\n- Includes many rule based optimizations such as predicate pushdown, limit\n pushdown, redundant join and redundant expression removal, to name a few.\n\n- Uses statistics on user data to select which index to use to access each\n table.\n\nWhat's next\n-----------\n\n- To learn more about the query optimizer, see [About query optimizer](/spanner/docs/query-optimizer/overview).\n- To manage both the optimizer version and statistics package for your scenario, see [Manage the query optimizer](/spanner/docs/query-optimizer/manage-query-optimizer)."]]