> [!NOTE] Table Function Scan > <table> > <tr> > <td width="25%"><img src="assets/ex_tablefuncscan.png"></td> > <td>Executes functions that return a set of rows (e.g., <code>xmltable</code> or <code>jsonb_to_recordset</code>). The engine calls the function and then treats its output as a virtual table that can be scanned, filtered, or joined like any other relation.</td> > </tr> > </table> > > ```sql > -- Querying a generated XML table > EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE) > SELECT * FROM xmltable('/root/item' > PASSING '<root><item>1</item><item>2</item></root>' > COLUMNS i int PATH '.'); > ``` > > ![TableFuncScan Plan Tree](assets/plan_tree_op_table_func_scan.svg) > > ```text > Table Function Scan on "xmltable" (cost=0.00..1.00 rows=100 width=4) (actual time=0.030..0.030 rows=2 loops=1) > Output: i > Table Function Call: XMLTABLE(('/root/item'::text) PASSING ('<root><item>1</item><item>2</item></root>'::xml) COLUMNS i integer PATH ('.'::text)) > Planning Time: 0.030 ms > Execution Time: 0.045 ms > ``` > > ![Table Function Scan measured plan performance signature](assets/trace_op_table_func_scan.svg) > > <table> > <tr> > <td rowspan="2" width="25%"><img src="assets/ex_table_func_scan.svg"></td> > <td><b>Performance</b></td><td>Depends on the complexity and volume of the generated table.</td> > </tr> > <tr><td><b>Cost</b></td><td><code>function cost + cpu_tuple_cost * number of rows</code></td></tr> > </table>