> [!NOTE] Function Scan > <table> > <tr> > <td width="25%"><img src="assets/ex_functionscan.png"></td> > <td>A scan node that executes a set-returning function. The engine materializes the entire result set of the function before scanning it, which can be a memory bottleneck if the function returns a massive volume of data.</td> > </tr> > </table> > > ```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) > ``` > > <table> > <tr> > <td rowspan="5" width="25%"><img src="assets/ex_table_func_scan.svg"></td> > <td><b>Performance</b></td><td>High performance for simple built-ins; performance is entirely dependent on the execution time of the underlying function.</td> > </tr> > <tr><td><b>Factors</b></td><td>Function logic complexity and the total number of tuples generated.</td></tr> > <tr><td><b>Cost</b></td><td><code>function cost + cpu_tuple_cost * number of tuples</code></td></tr> > <tr><td><b>Operates on</b></td><td><a href="Structures/Result Set">Result Set</a></td></tr> > <tr><td><b>Workloads</b></td><td><a href="Workloads/LWLock/Buffers/BufferContent">LWLock: BufferContent</a></td></tr> > <tr><td colspan="3"><b>Description</b>: Executes a table-returning function and scans its output.</td></tr> > </table>