### Function Scan ![[assets/ex_functionscan.png|256]] ### The Explain Trace ```sql -- Scanning the output of generate_series EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE) SELECT * FROM generate_series(1,5); ``` ```text Function Scan on pg_catalog.generate_series (cost=1.00..1.05 rows=5 width=4) (actual time=1.003..1.003 rows=5 loops=1) Output: generate_series Function Call: generate_series(1, 5) ``` --- - **Description**: Executes a table-returning function and scans its output. - **Performance**: High performance for simple built-ins; performance is entirely dependent on the execution time of the underlying function. - **Factors**: Function logic complexity and the total number of tuples generated. - **Cost**: `function cost + cpu_tuple_cost * number of tuples` ![[assets/ex_table_func_scan.svg|256]] - **Operates on**: [[Structures/Result Set]] - **Workloads**: - [[Workloads/LWLock/Buffers/BufferContent|LWLock: BufferContent]]