Details
-
Task
-
Status: Stalled (View Workflow)
-
Major
-
Resolution: Unresolved
-
Q2/2026 Server Development, Q3/2026 Server Development
Description
Current idea about shipping results from worker threads to the main thread is to use temporary (work) tables.
In a situation with N workers:
The primary thread creates N temporary tables, passes them over to the workers (each gets its own).
Each worker writes the results of its query portion into its temporary table.
Then, it notifies the primary thread that it is done.
After that, the worker doesn't access the table anymore.
The primary thread reads the data from the temp table and either does further processing or just sends it back to the client.
Questions
Need to verify that the following works:
Q1: Verify that temp.table can be created in thread1 and used in thread2
Assume that here is no concurrent access. Just check that no assert fires/etc.
Q2: How can one create multiple tmp. tables? How does one do that?
Consider code implementing SELECT SQL_BUFFER_RESULT. It creates a temp.table. Can we create multiple temporary tables with this? (Or we'll need a multiple TMP_TABLE_PARAM structures? )
MS 0.1: Create/Free multiple temp.tables
Make use of this property: SQL_BUFFER_RESULT causes the server to buffer the query output in a temporary table. Make it so that
set parallel_worker_threads=N; |
select SQL_BUFFER_RESULT * from t1; |
will create (and eventually free) N temporary tables.
Only the first created table should be used for storing the rows.
MS 0.2: Test that putting data into a temp. table works
The idea is to test that another thread can write data into a temp table.
Create a dummy function to write a row into a table. Let it write either default values or some other pre-defined values (denote this TEST-ROW).
Use that function in worker threads to write a row into the table.
Then, the main query should collect data from the temp.tables and send them to the output.
Thus, the query output with N workers will have N extra rows with values of TEST-ROW.