Madison Digital Garden

Search

SearchSearch

Sequential Scan Callstack (Postgres Coderef)

Dec 16, 2024, 1 min read

  • #database
  • #db-postgresql
  • #story

개요 §

  • 본 작물에서는 PostgreSQL 에서 sequential scan (가령 SELECT * FROM table;) 을 했을때의 function call stack 을 정리해 본다.

Stack §

  • 우선 공통 로직 을 처리한 다음, Executor, Access Method Call Path 부터 시작한다.

Executor, Access Method Call Path §

  • ExecSeqScan()
    • ExecScan()
      • ExecScanFetch()
        • SeqNext()
          • table_beginscan()
            • heap_beginscan()
          • table_scan_getnextslot()
            • heap_getnextslot()
              • heapgettup_pagemode()
                • heapgettup_continue_page()
                • heap_fetch_next_buffer()
                  • Call path: read_stream_next_buffer()

read_stream_next_buffer() Call Path §

  • read_stream_next_buffer()
    • Call Path: read_stream_get_block()
    • StartReadBuffer()
      • Call Path: StartReadBuffersImpl()
    • Call Path: read_stream_look_ahead()
    • WaitReadBuffers()
      • WaitReadBuffersCanStartIO()
      • smgrreadv()
        • mdreadv()
          • FileReadV()
    • Call Path: read_stream_look_ahead()

StartReadBuffersImpl() Call Path §

  • StartReadBuffersImpl()
    • PinBufferForBlock()
      • BufferAlloc()
    • smgrprefetch()
      • mdprefetch()
        • FilePrefetch()

read_stream_get_block() Call Path §

  • read_stream_get_block()
    • heap_scan_stream_read_next_serial()
      • heapgettup_initial_block()
      • heapgettup_advance_block()

read_stream_look_ahead() Call Path §

  • read_stream_look_ahead()
    • Call Path: read_stream_get_block()
    • read_stream_start_pending_read()
      • StartReadBuffers()
        • Call Path: StartReadBuffersImpl()

Graph View

  • 개요
  • Stack
  • Executor, Access Method Call Path
  • read_stream_next_buffer() Call Path
  • StartReadBuffersImpl() Call Path
  • read_stream_get_block() Call Path
  • read_stream_look_ahead() Call Path

Backlinks

  • Postgres Code Reference

Created with Quartz v4.1.0, © 2025

  • GitHub
  • LinkedIn
  • Email