Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CBRD-25997] Skip end_one_iteration when it's possible in parallel heap scan #6091

Open
wants to merge 19 commits into
base: feature/parallel_query
Choose a base branch
from

Conversation

xmilex-git
Copy link
Contributor

@xmilex-git xmilex-git commented Apr 5, 2025

http://jira.cubrid.org/browse/CBRD-25997

Purpose

기존에는 병렬 힙 스캔 수행 후, 메인 스레드가 각 스레드로부터 결과를 한 건씩 받아 xasl->list_id에 추가하는 방식으로 처리되었습니다. 그러나 이 방식은 첨부된 그래프에서 확인할 수 있듯이 성능 저하가 큽니다.

이에 따라, 병렬 힙 스캔을 수행한 스레드에서 생성한 임시 결과 파일을 별도의 병합 없이 그대로 클라이언트에 반환하거나 쿼리의 결과로 사용할 수 있도록 개선하였습니다.

병렬 힙 스캔 수행 시 다음 조건을 모두 만족하는 경우, end_one_iteration 등의 후처리를 생략하고 병렬 힙 스캔 스레드에서 생성한 임시 결과 파일을 최종 결과로 바로 반환하도록 동작이 수정됩니다.

  • TOP_MOST_XASL이거나, uncorrelated subquery일 경우
  • 병렬 힙 스캔이 가능한 경우
  • if_pred가 없는 경우 (이는 objfetch proc이나 connect by proc에서 사용되므로, 병렬 힙 스캔이 가능한 경우에는 if_pred가 존재하지 않음)
  • topn_sort를 하지 않는 경우
  • hash_aggregate (group by 등) 을 하지 않는 경우
  • select-list에 set, multiset, sequence 등이 포함되지 않는 경우
  • (차후 지원 예정) end_one_iteration에서 fetch 수행되는 select-list에 arithmetic expression, function expression, sp expression이 없는 경우
  • buildvalue proc -> agg_list 가 없는 경우 (count(*) 등)
  • rownum과 같은 instnum_val이 없는 경우
  • (차후 지원 예정) LIMIT 1과 같은 instnum_pred가 없는 경우
  • (차후 지원 예정) interpolation 함수 (median, percentile_cont, percentile_dist, cume_dist, percent_rank등)

대표적인 적용 예시

  • 조인이 없는 단순 테이블 full scan 쿼리 또는 uncorrelated subquery
  • 테이블 full scan 이후 ORDER BY, GROUP BY, 집계 함수 등의 후처리를 수행하는 쿼리

Implementation

scan_next_parallel_heap_scan()에서 LIST_MERGE 방식으로 결과를 처리하는 parallel heap scan manager가 존재하는 경우, 자식 스레드가 모두 종료될 때까지 대기한 후 리스트 병합(list merging)을 수행하고, S_END를 반환하여 end_one_iteration이나 추가적인 pred 평가 과정을 생략합니다.
이때 xasl->list_id에 저장된 리스트는 병합된 결과 리스트로 대체됩니다.

Remarks

  • end_one_iteration을 생략하는 경우 topn_sort 기능을 제한합니다.
  • Parallel heap scan trace 내용이 변경됩니다. (parallelism, min, max, gather 방법 출력)

xmilex-git and others added 12 commits April 2, 2025 16:28
http://jira.cubrid.org/browse/CBRD-25447

To improve the performance of heap scan, we plan to add a parallel heap scan feature to CUBRID.
The following improvements that have not yet been completed will be handled in separate improvement issues/PRs.
  •  Trace output
  •  Modify the query to allow specifying the number of threads using a query hint, e.g., select /*+ parallel(4) */ * from t1;
  •  Store the results separately in individual list files for each parallel task thread, to be later merged or used as needed
@xmilex-git xmilex-git self-assigned this Apr 5, 2025
@xmilex-git xmilex-git changed the base branch from feature/parallel_heap_scan to feature/parallel_query April 7, 2025 03:04
@xmilex-git xmilex-git requested a review from hornetmj as a code owner April 7, 2025 03:04
@xmilex-git xmilex-git removed the request for review from hornetmj April 7, 2025 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant