Details
-
New Feature
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
A derived_handler that reports supports_streaming() gets ha_derived_stream as the handler of the derived table's temporary table: rnd_next() is the engine's next_row() written straight into record[0], nothing is filled beforehand.
API (sql/derived_handler.h)
- virtual bool supports_streaming() const (default false)
- virtual void get_estimates(ha_rows *rows, double *scan_time, double *startup_cost) - row count and cost for the optimizer
- virtual int rescan() (default end_scan() + init_scan())
- new class ha_derived_stream (scan-only handler, no keys, no positions)
- TABLE_LIST::derived_streamed, TABLE_LIST::derived_saved_file
Optimizer behaviour
- the streamed table counts as filled at execution: no constant detection, no range analysis
- row/cost estimates come from derived_handler::get_estimates()
- no derived keys, no join buffer
- at the end of JOIN::make_aggr_tables_info the stream is kept only where the join reads the table first, as a plain unsorted scan; otherwise the temporary table gets its own handler back and the engine fills it as before (Pushdown_derived)
Lifetime
- the stream handler is opened at prepare, when installed
- the engine's estimates are taken once, in the constructor, because free_pushdown_handlers deletes the derived_handler before the temporary table is freed
- ha_derived_stream::detach() / detach_from() drop the reference to the freed derived_handler; only a handler that is a stream is touched
Commits (branch orthus/derived-late-decline, MariaDBEnterprise)
- ec25ba14774 MDEV: derived_handler may stream its rows into the join (no temporary table)
- 3050582acfa derived stream: open at prepare, detach before the handler is freed
- b3d15c87488 derived stream: detach only a handler that is a stream