ClickHouse / ClickHouse/ClickHouse

The serial execution of UNION ALL with GLOBAL IN subqueries leads to performance degradation

Open
#66,057 0 comments 0 reactions 0 assignees View on GitHub
comp-query-execution external
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
20h 33m
Merged PRs (30d)
501

Description

Problem 1: The serial execution of UNION ALL with GLOBAL IN subqueries leads to performance degradation.

I’ve observed a performance difference between using UNION ALL + GLOBAL IN and regular UNION ALL in queries.
By adding sleep(3) to the SQL, in version 23.2.5, the UNION ALL + GLOBAL IN query took 9 seconds, while the regular UNION ALL took only 3 seconds.
In version 24.5.4.49, the times increased to 12 seconds and 6 seconds respectively, suggesting that GLOBAL IN may be executing sequentially.

The findings suggest that GLOBAL IN behaves more like sequential execution which significantly impacts performance compared to the standard UNION ALL

Problem 2: Version 24.5.4.49 takes 3 seconds longer than version 23.2.5, and it appears that 24.5.4.49 waits for the results from the child nodes before executing the node.

**UNION ALL+GLOBAL IN**
```sql
SELECT *
FROM
(
SELECT * FROM employees_test_a
WHERE (name, 0) GLOBAL IN (
SELECT name, sleep(3)
FROM employees_test_a
WHERE name = 'Charlie'
ORDER BY age ASC
LIMIT 10
)
UNION ALL
SELECT * FROM employees_test_b
WHERE (name, 0) GLOBAL IN (
SELECT name, sleep(3)
FROM employees_test_b
WHERE name = 'Charlie'
ORDER BY age ASC
LIMIT 10
)
UNION ALL
SELECT * FROM employees_test_c
WHERE (name, 0) GLOBAL IN (
SELECT name, sleep(3)
FROM employees_test_c
WHERE name = 'Charlie'
ORDER BY age ASC
LIMIT 10
)
)
LIMIT 10
SETTINGS max_threads = 20;
```

```

[ccc83b374c0f] 2024.07.02 12:23:18.776651 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} executeQuery: (from 127.0.0.1:53064) SELECT * FROM ( SELECT * FROM employees_test_a WHERE (name ,0 )GLOBAL IN ( SELECT name,sleep(3) FROM employees_test_a WHERE name = 'Charlie' ORDER BY age ASC LIMIT 10 ) UNION ALL SELECT * FROM employees_test_b WHERE (name ,0 )GLOBAL IN ( SELECT name,sleep(3) FROM employees_test_b WHERE name = 'Charlie' ORDER BY age ASC LIMIT 10 ) UNION ALL SELECT * FROM employees_test_c WHERE (name ,0 )GLOBAL IN ( SELECT name,sleep(3) FROM employees_test_c WHERE name = 'Charlie' ORDER BY age ASC LIMIT 10 ) ) LIMIT 10 SETTINGS max_threads = 20; (stage: Complete)
[ccc83b374c0f] 2024.07.02 12:23:18.794869 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:18.795945 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Selected 2/2 parts by partition key, 2 parts by primary key, 2/2 marks by primary key, 2 marks to read from 2 ranges
[ccc83b374c0f] 2024.07.02 12:23:18.796368 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} MergeTreeReadPool: min_marks_for_concurrent_read=24
[ccc83b374c0f] 2024.07.02 12:23:18.796460 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Reading approx. 26 rows with 2 streams
[ccc83b374c0f] 2024.07.02 12:23:18.800431 [ 794 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.000129417 sec., 14067 rows/sec., 68.00 B (466.97 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (1015.74 KiB/sec.)
[5530a9f7ca56] 2024.07.02 12:23:18.802267 [ 49 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} executeQuery: (from 172.20.0.2:45182, initial_query_id: 7ddbd43c-db8c-43c0-8401-7e6e37aecfa2) SELECT `__table1`.`name` AS `name`, sleep(3) AS `sleep(3)` FROM `employees_test_a_local` AS `__table1` WHERE `__table1`.`name` = 'Charlie' ORDER BY `__table1`.`age` ASC LIMIT _CAST(10, 'UInt64') (stage: WithMergeableStateAfterAggregationAndLimit)
[5530a9f7ca56] 2024.07.02 12:23:18.805459 [ 49 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:18.806069 [ 49 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Selected 2/2 parts by partition key, 2 parts by primary key, 2/2 marks by primary key, 2 marks to read from 2 ranges
[5530a9f7ca56] 2024.07.02 12:23:18.806506 [ 49 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} MergeTreeReadPool: min_marks_for_concurrent_read=24
[5530a9f7ca56] 2024.07.02 12:23:18.806611 [ 49 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Reading approx. 34 rows with 2 streams
[5530a9f7ca56] 2024.07.02 12:23:21.817668 [ 806 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} MergingSortedTransform: Merge sorted 2 blocks, 1 rows in 3.010000002 sec., 0.3322259134005143 rows/sec., 5.65 B/sec
[5530a9f7ca56] 2024.07.02 12:23:21.819976 [ 49 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} executeQuery: Read 34 rows, 487.00 B in 3.018254 sec., 11.26479083602639 rows/sec., 161.35 B/sec.
[5530a9f7ca56] 2024.07.02 12:23:21.820830 [ 49 ] {aee2d5ed-6ceb-406c-a03d-23e387ef3f72} TCPHandler: Processed in 3.020362834 sec.
[ccc83b374c0f] 2024.07.02 12:23:24.826527 [ 798 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} MergingSortedTransform: Merge sorted 3 blocks, 5 rows in 6.030000003 sec., 0.8291873959390444 rows/sec., 14.10 B/sec
[ccc83b374c0f] 2024.07.02 12:23:24.828283 [ 731 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} MergingSortedTransform: Merge sorted 4 blocks, 6 rows in 6.031000003 sec., 0.994859890070539 rows/sec., 17.91 B/sec
[ccc83b374c0f] 2024.07.02 12:23:24.847873 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:24.848797 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[ccc83b374c0f] 2024.07.02 12:23:24.848933 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[ccc83b374c0f] 2024.07.02 12:23:24.854052 [ 787 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.000314708 sec., 6066 rows/sec., 68.00 B (201.38 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (438.25 KiB/sec.)
[5530a9f7ca56] 2024.07.02 12:23:24.856887 [ 49 ] {87656b82-d2db-4bc7-a365-40fa67012e81} executeQuery: (from 172.20.0.2:45182, initial_query_id: 7ddbd43c-db8c-43c0-8401-7e6e37aecfa2) SELECT `__table1`.`name` AS `name`, sleep(3) AS `sleep(3)` FROM `employees_test_b_local` AS `__table1` WHERE `__table1`.`name` = 'Charlie' ORDER BY `__table1`.`age` ASC LIMIT _CAST(10, 'UInt64') (stage: WithMergeableStateAfterAggregationAndLimit)
[5530a9f7ca56] 2024.07.02 12:23:24.861889 [ 49 ] {87656b82-d2db-4bc7-a365-40fa67012e81} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:24.862324 [ 49 ] {87656b82-d2db-4bc7-a365-40fa67012e81} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[5530a9f7ca56] 2024.07.02 12:23:24.862419 [ 49 ] {87656b82-d2db-4bc7-a365-40fa67012e81} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[5530a9f7ca56] 2024.07.02 12:23:27.870375 [ 49 ] {87656b82-d2db-4bc7-a365-40fa67012e81} executeQuery: Read 22 rows, 327.00 B in 3.014537 sec., 7.2979698043182095 rows/sec., 108.47 B/sec.
[5530a9f7ca56] 2024.07.02 12:23:27.871507 [ 49 ] {87656b82-d2db-4bc7-a365-40fa67012e81} TCPHandler: Processed in 3.017454918 sec.
[ccc83b374c0f] 2024.07.02 12:23:27.872850 [ 749 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} MergingSortedTransform: Merge sorted 3 blocks, 6 rows in 3.023000001 sec., 1.9847833271634854 rows/sec., 35.73 B/sec
[ccc83b374c0f] 2024.07.02 12:23:27.905924 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:27.910019 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[ccc83b374c0f] 2024.07.02 12:23:27.910445 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[ccc83b374c0f] 2024.07.02 12:23:27.929219 [ 763 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.000146541 sec., 11516 rows/sec., 68.00 B (382.29 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (831.83 KiB/sec.)
[5530a9f7ca56] 2024.07.02 12:23:27.932719 [ 49 ] {84cbfed0-fe0f-41a0-8074-5183c77ca26a} executeQuery: (from 172.20.0.2:45182, initial_query_id: 7ddbd43c-db8c-43c0-8401-7e6e37aecfa2) SELECT `__table1`.`name` AS `name`, sleep(3) AS `sleep(3)` FROM `employees_test_c_local` AS `__table1` WHERE `__table1`.`name` = 'Charlie' ORDER BY `__table1`.`age` ASC LIMIT _CAST(10, 'UInt64') (stage: WithMergeableStateAfterAggregationAndLimit)
[5530a9f7ca56] 2024.07.02 12:23:27.944960 [ 49 ] {84cbfed0-fe0f-41a0-8074-5183c77ca26a} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:27.945420 [ 49 ] {84cbfed0-fe0f-41a0-8074-5183c77ca26a} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[5530a9f7ca56] 2024.07.02 12:23:27.945560 [ 49 ] {84cbfed0-fe0f-41a0-8074-5183c77ca26a} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[5530a9f7ca56] 2024.07.02 12:23:30.957740 [ 49 ] {84cbfed0-fe0f-41a0-8074-5183c77ca26a} executeQuery: Read 36 rows, 526.00 B in 3.025915 sec., 11.897227780687825 rows/sec., 173.83 B/sec.
[5530a9f7ca56] 2024.07.02 12:23:30.959956 [ 49 ] {84cbfed0-fe0f-41a0-8074-5183c77ca26a} TCPHandler: Processed in 3.030799668 sec.
[ccc83b374c0f] 2024.07.02 12:23:30.961550 [ 763 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} MergingSortedTransform: Merge sorted 3 blocks, 7 rows in 3.044000001 sec., 2.2996057811105106 rows/sec., 41.39 B/sec
[ccc83b374c0f] 2024.07.02 12:23:30.978121 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} CreatingSetsTransform: Created Set with 1 entries from 6 rows in 0.000132625 sec.
[ccc83b374c0f] 2024.07.02 12:23:30.978823 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} CreatingSetsTransform: Created Set with 1 entries from 7 rows in 1.475e-05 sec.
[ccc83b374c0f] 2024.07.02 12:23:30.979529 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:30.982663 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Selected 2/2 parts by partition key, 2 parts by primary key, 2/2 marks by primary key, 2 marks to read from 2 ranges
[ccc83b374c0f] 2024.07.02 12:23:30.983034 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} MergeTreeReadPool: min_marks_for_concurrent_read=24
[ccc83b374c0f] 2024.07.02 12:23:30.983143 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Reading approx. 26 rows with 2 streams
[ccc83b374c0f] 2024.07.02 12:23:30.984251 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:30.985035 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[ccc83b374c0f] 2024.07.02 12:23:30.985123 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[ccc83b374c0f] 2024.07.02 12:23:30.985624 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:30.985990 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[ccc83b374c0f] 2024.07.02 12:23:30.986053 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[ccc83b374c0f] 2024.07.02 12:23:30.994117 [ 813 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} CreatingSetsTransform: Created Set with 1 entries from 6 rows in 0.00054225 sec.
[ccc83b374c0f] 2024.07.02 12:23:30.998444 [ 764 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.000176 sec., 9768 rows/sec., 68.00 B (324.26 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (705.17 KiB/sec.)
[ccc83b374c0f] 2024.07.02 12:23:30.998443 [ 816 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.000190709 sec., 9445 rows/sec., 68.00 B (313.54 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (682.29 KiB/sec.)
┌─id─┬─name────┬─age─┬─salary─┐
1. │ 3 │ Charlie │ 35 │ 80000 │
2. │ 3 │ Charlie │ 35 │ 80000 │
└────┴─────────┴─────┴────────┘
┌─id─┬─name────┬─age─┬─salary─┐
3. │ 3 │ Charlie │ 35 │ 80000 │
4. │ 3 │ Charlie │ 35 │ 80000 │
5. │ 3 │ Charlie │ 35 │ 80000 │
6. │ 3 │ Charlie │ 35 │ 80000 │
└────┴─────────┴─────┴────────┘
[ccc83b374c0f] 2024.07.02 12:23:31.000940 [ 764 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 1 external tables, total 6 rows in 0.000420333 sec., 14246 rows/sec., 103.00 B (238.80 KiB/sec.), compressed 0.6023391812865497 times to 171.00 B (396.42 KiB/sec.)
[ccc83b374c0f] 2024.07.02 12:23:31.002625 [ 804 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.004602875 sec., 433 rows/sec., 68.00 B (14.39 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (31.33 KiB/sec.)
[ccc83b374c0f] 2024.07.02 12:23:31.003666 [ 804 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 1 external tables, total 6 rows in 0.00044325 sec., 13503 rows/sec., 103.00 B (226.35 KiB/sec.), compressed 0.6094674556213018 times to 169.00 B (371.19 KiB/sec.)
[ccc83b374c0f] 2024.07.02 12:23:31.003905 [ 816 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} Connection (clickhouse1:9000): Sent data for 1 external tables, total 7 rows in 0.000794583 sec., 8801 rows/sec., 112.00 B (137.49 KiB/sec.), compressed 0.6549707602339181 times to 171.00 B (209.88 KiB/sec.)
[5530a9f7ca56] 2024.07.02 12:23:31.003404 [ 49 ] {60f6f149-895a-48e1-9118-77fc45468d71} executeQuery: (from 172.20.0.2:45182, initial_query_id: 7ddbd43c-db8c-43c0-8401-7e6e37aecfa2) SELECT `__table1`.`id` AS `id`, `__table1`.`name` AS `name`, `__table1`.`age` AS `age`, `__table1`.`salary` AS `salary` FROM `employees_test_a_local` AS `__table1` WHERE (`__table1`.`name`, 0) GLOBAL IN (`_data_6675875822765124622_304668313962167844` AS `__table2`) (stage: Complete)
[5530a9f7ca56] 2024.07.02 12:23:31.002019 [ 726 ] {de156b15-0a18-401e-9eb3-dcb02d699b29} executeQuery: (from 172.20.0.2:38982, initial_query_id: 7ddbd43c-db8c-43c0-8401-7e6e37aecfa2) SELECT `__table1`.`id` AS `id`, `__table1`.`name` AS `name`, `__table1`.`age` AS `age`, `__table1`.`salary` AS `salary` FROM `employees_test_c_local` AS `__table1` WHERE (`__table1`.`name`, 0) GLOBAL IN (`_data_5822282793425737982_9324937739599981152` AS `__table2`) (stage: Complete)
[5530a9f7ca56] 2024.07.02 12:23:31.002527 [ 50 ] {55399bac-0782-4760-a746-13de9e09a93a} executeQuery: (from 172.20.0.2:38966, initial_query_id: 7ddbd43c-db8c-43c0-8401-7e6e37aecfa2) SELECT `__table1`.`id` AS `id`, `__table1`.`name` AS `name`, `__table1`.`age` AS `age`, `__table1`.`salary` AS `salary` FROM `employees_test_b_local` AS `__table1` WHERE (`__table1`.`name`, 0) GLOBAL IN (`_data_7512284419771628191_15195846122823830304` AS `__table2`) (stage: Complete)
[5530a9f7ca56] 2024.07.02 12:23:31.013932 [ 726 ] {de156b15-0a18-401e-9eb3-dcb02d699b29} CreatingSetsTransform: Created Set with 1 entries from 7 rows in 0.000277958 sec.
[5530a9f7ca56] 2024.07.02 12:23:31.014566 [ 726 ] {de156b15-0a18-401e-9eb3-dcb02d699b29} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:31.016733 [ 726 ] {de156b15-0a18-401e-9eb3-dcb02d699b29} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[5530a9f7ca56] 2024.07.02 12:23:31.017049 [ 726 ] {de156b15-0a18-401e-9eb3-dcb02d699b29} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[5530a9f7ca56] 2024.07.02 12:23:31.024781 [ 726 ] {de156b15-0a18-401e-9eb3-dcb02d699b29} executeQuery: Read 43 rows, 933.00 B in 0.02411 sec., 1783.492326835338 rows/sec., 37.79 KiB/sec.
[5530a9f7ca56] 2024.07.02 12:23:31.025290 [ 726 ] {de156b15-0a18-401e-9eb3-dcb02d699b29} TCPHandler: Processed in 0.026815708 sec.
[5530a9f7ca56] 2024.07.02 12:23:31.012356 [ 50 ] {55399bac-0782-4760-a746-13de9e09a93a} CreatingSetsTransform: Created Set with 1 entries from 6 rows in 7.6209e-05 sec.
[5530a9f7ca56] 2024.07.02 12:23:31.012765 [ 50 ] {55399bac-0782-4760-a746-13de9e09a93a} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:31.013510 [ 50 ] {55399bac-0782-4760-a746-13de9e09a93a} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[5530a9f7ca56] 2024.07.02 12:23:31.013790 [ 50 ] {55399bac-0782-4760-a746-13de9e09a93a} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[5530a9f7ca56] 2024.07.02 12:23:31.035128 [ 50 ] {55399bac-0782-4760-a746-13de9e09a93a} executeQuery: Read 28 rows, 605.00 B in 0.034713 sec., 806.6142367412784 rows/sec., 17.02 KiB/sec.
[5530a9f7ca56] 2024.07.02 12:23:31.035292 [ 50 ] {55399bac-0782-4760-a746-13de9e09a93a} TCPHandler: Processed in 0.036503625 sec.
[5530a9f7ca56] 2024.07.02 12:23:31.025518 [ 49 ] {60f6f149-895a-48e1-9118-77fc45468d71} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:31.027420 [ 49 ] {60f6f149-895a-48e1-9118-77fc45468d71} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Selected 2/2 parts by partition key, 2 parts by primary key, 2/2 marks by primary key, 2 marks to read from 2 ranges
[5530a9f7ca56] 2024.07.02 12:23:31.027836 [ 49 ] {60f6f149-895a-48e1-9118-77fc45468d71} MergeTreeReadPool: min_marks_for_concurrent_read=24
[5530a9f7ca56] 2024.07.02 12:23:31.027977 [ 49 ] {60f6f149-895a-48e1-9118-77fc45468d71} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Reading approx. 34 rows with 2 streams
[5530a9f7ca56] 2024.07.02 12:23:31.033555 [ 758 ] {60f6f149-895a-48e1-9118-77fc45468d71} CreatingSetsTransform: Created Set with 1 entries from 6 rows in 0.000201541 sec.
[5530a9f7ca56] 2024.07.02 12:23:31.037925 [ 49 ] {60f6f149-895a-48e1-9118-77fc45468d71} executeQuery: Read 40 rows, 866.00 B in 0.037206 sec., 1075.0954147180562 rows/sec., 22.73 KiB/sec.
[5530a9f7ca56] 2024.07.02 12:23:31.038066 [ 49 ] {60f6f149-895a-48e1-9118-77fc45468d71} TCPHandler: Processed in 0.039616458 sec.
┌─id─┬─name────┬─age─┬─salary─┐
7. │ 3 │ Charlie │ 35 │ 80000 │
8. │ 3 │ Charlie │ 35 │ 80000 │
9. │ 3 │ Charlie │ 35 │ 80000 │
10. │ 3 │ Charlie │ 35 │ 80000 │
└────┴─────────┴─────┴────────┘
[ccc83b374c0f] 2024.07.02 12:23:31.052011 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} executeQuery: Read 418 rows, 7.57 KiB in 12.277213 sec., 34.04681502226931 rows/sec., 631.01 B/sec.
[ccc83b374c0f] 2024.07.02 12:23:31.055962 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} MemoryTracker: Peak memory usage (for query): 4.94 MiB.
[ccc83b374c0f] 2024.07.02 12:23:31.056118 [ 726 ] {7ddbd43c-db8c-43c0-8401-7e6e37aecfa2} TCPHandler: Processed in 12.283379172 sec.

10 rows in set. Elapsed: 12.279 sec.

```

**UNION ALL :**
```sql
SELECT *
FROM
(
SELECT *,sleep(3) FROM employees_test_a
WHERE name = 'Charlie'
ORDER BY id ASC
LIMIT 10
UNION ALL
SELECT *,sleep(3) FROM employees_test_b
WHERE name = 'Charlie'
ORDER BY id ASC
LIMIT 10
UNION ALL
SELECT *,sleep(3) FROM employees_test_c
WHERE name = 'Charlie'
ORDER BY id ASC
LIMIT 10

)
LIMIT 10
SETTINGS max_threads = 20;
```

```
[ccc83b374c0f] 2024.07.02 12:23:45.898882 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} executeQuery: (from 127.0.0.1:53064) SELECT * FROM ( SELECT *,sleep(3) FROM employees_test_a WHERE name = 'Charlie' ORDER BY id ASC LIMIT 10 UNION ALL SELECT *,sleep(3) FROM employees_test_b WHERE name = 'Charlie' ORDER BY id ASC LIMIT 10 UNION ALL SELECT *,sleep(3) FROM employees_test_c WHERE name = 'Charlie' ORDER BY id ASC LIMIT 10 ) LIMIT 10 SETTINGS max_threads = 20; (stage: Complete)
[ccc83b374c0f] 2024.07.02 12:23:45.956891 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:45.958915 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_a_local (cc1c8acf-6bd1-48ea-89fa-81bf443de465) (SelectExecutor): Selected 2/2 parts by partition key, 2 parts by primary key, 2/2 marks by primary key, 2 marks to read from 2 ranges
[ccc83b374c0f] 2024.07.02 12:23:45.960168 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:45.960760 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[ccc83b374c0f] 2024.07.02 12:23:45.960840 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_b_local (c506f988-15b9-414c-b94e-29ff88163917) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[ccc83b374c0f] 2024.07.02 12:23:45.961186 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Key condition: unknown
[ccc83b374c0f] 2024.07.02 12:23:45.961451 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[ccc83b374c0f] 2024.07.02 12:23:45.961494 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} default.employees_test_c_local (d8d1bfa4-dbe7-4000-864e-c22c470260e2) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[ccc83b374c0f] 2024.07.02 12:23:45.972701 [ 828 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 7.5667e-05 sec., 26143 rows/sec., 68.00 B (867.11 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (1.84 MiB/sec.)
[5530a9f7ca56] 2024.07.02 12:23:45.973899 [ 726 ] {c290ef2c-2a26-4b9b-94d9-ae495b79076a} executeQuery: (from 172.20.0.2:38982, initial_query_id: e92075fb-1fe8-4762-992c-a5917e8edc9a) SELECT `__table1`.`id` AS `id`, `__table1`.`name` AS `name`, `__table1`.`age` AS `age`, `__table1`.`salary` AS `salary`, sleep(3) AS `sleep(3)` FROM `employees_test_a_local` AS `__table1` WHERE `__table1`.`name` = 'Charlie' ORDER BY `__table1`.`id` ASC LIMIT _CAST(10, 'UInt64') (stage: WithMergeableStateAfterAggregationAndLimit)
[ccc83b374c0f] 2024.07.02 12:23:45.969457 [ 830 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.000172792 sec., 10088 rows/sec., 68.00 B (334.89 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (728.58 KiB/sec.)
[5530a9f7ca56] 2024.07.02 12:23:45.971684 [ 50 ] {d3b2712e-7475-4e8a-8051-16d15b53ea7a} executeQuery: (from 172.20.0.2:38966, initial_query_id: e92075fb-1fe8-4762-992c-a5917e8edc9a) SELECT `__table1`.`id` AS `id`, `__table1`.`name` AS `name`, `__table1`.`age` AS `age`, `__table1`.`salary` AS `salary`, sleep(3) AS `sleep(3)` FROM `employees_test_c_local` AS `__table1` WHERE `__table1`.`name` = 'Charlie' ORDER BY `__table1`.`id` ASC LIMIT _CAST(10, 'UInt64') (stage: WithMergeableStateAfterAggregationAndLimit)
[5530a9f7ca56] 2024.07.02 12:23:45.977318 [ 726 ] {c290ef2c-2a26-4b9b-94d9-ae495b79076a} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:45.979421 [ 726 ] {c290ef2c-2a26-4b9b-94d9-ae495b79076a} default.employees_test_a_local (492c5f0b-2494-4c33-b500-78f84979065d) (SelectExecutor): Selected 2/2 parts by partition key, 2 parts by primary key, 2/2 marks by primary key, 2 marks to read from 2 ranges
[5530a9f7ca56] 2024.07.02 12:23:45.979654 [ 50 ] {d3b2712e-7475-4e8a-8051-16d15b53ea7a} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:45.980157 [ 50 ] {d3b2712e-7475-4e8a-8051-16d15b53ea7a} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[5530a9f7ca56] 2024.07.02 12:23:45.980236 [ 50 ] {d3b2712e-7475-4e8a-8051-16d15b53ea7a} default.employees_test_c_local (0afc693e-cc51-45d0-a479-6a4909588246) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[ccc83b374c0f] 2024.07.02 12:23:48.975424 [ 824 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} Connection (clickhouse1:9000): Sent data for 2 scalars, total 2 rows in 0.000369584 sec., 5185 rows/sec., 68.00 B (172.13 KiB/sec.), compressed 0.4594594594594595 times to 148.00 B (374.55 KiB/sec.)
[5530a9f7ca56] 2024.07.02 12:23:48.977936 [ 49 ] {a2c4a146-7f4c-4eb6-a592-56f18dce2c19} executeQuery: (from 172.20.0.2:45182, initial_query_id: e92075fb-1fe8-4762-992c-a5917e8edc9a) SELECT `__table1`.`id` AS `id`, `__table1`.`name` AS `name`, `__table1`.`age` AS `age`, `__table1`.`salary` AS `salary`, sleep(3) AS `sleep(3)` FROM `employees_test_b_local` AS `__table1` WHERE `__table1`.`name` = 'Charlie' ORDER BY `__table1`.`id` ASC LIMIT _CAST(10, 'UInt64') (stage: WithMergeableStateAfterAggregationAndLimit)
┌─id─┬─name────┬─age─┬─salary─┬─sleep(3)─┐
1. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
2. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
3. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
4. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
└────┴─────────┴─────┴────────┴──────────┘
┌─id─┬─name────┬─age─┬─salary─┬─sleep(3)─┐
5. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
6. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
7. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
└────┴─────────┴─────┴────────┴──────────┘
[5530a9f7ca56] 2024.07.02 12:23:48.986721 [ 50 ] {d3b2712e-7475-4e8a-8051-16d15b53ea7a} executeQuery: Read 36 rows, 814.00 B in 3.015711 sec., 11.937483399437147 rows/sec., 269.92 B/sec.
[5530a9f7ca56] 2024.07.02 12:23:48.987038 [ 50 ] {d3b2712e-7475-4e8a-8051-16d15b53ea7a} TCPHandler: Processed in 3.01765946 sec.
[ccc83b374c0f] 2024.07.02 12:23:48.987760 [ 827 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} MergingSortedTransform: Merge sorted 3 blocks, 7 rows in 3.025000001 sec., 2.3140495860118846 rows/sec., 60.17 B/sec
[5530a9f7ca56] 2024.07.02 12:23:48.981795 [ 49 ] {a2c4a146-7f4c-4eb6-a592-56f18dce2c19} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Key condition: unknown
[5530a9f7ca56] 2024.07.02 12:23:48.982360 [ 49 ] {a2c4a146-7f4c-4eb6-a592-56f18dce2c19} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Index `name_index` has dropped 0/1 granules.
[5530a9f7ca56] 2024.07.02 12:23:48.982454 [ 49 ] {a2c4a146-7f4c-4eb6-a592-56f18dce2c19} default.employees_test_b_local (b12352ec-dd33-497c-b199-6714b8f4d562) (SelectExecutor): Selected 1/1 parts by partition key, 1 parts by primary key, 1/1 marks by primary key, 1 marks to read from 1 ranges
[5530a9f7ca56] 2024.07.02 12:23:49.000248 [ 756 ] {c290ef2c-2a26-4b9b-94d9-ae495b79076a} MergingSortedTransform: Merge sorted 2 blocks, 1 rows in 3.020000001 sec., 0.3311258277049252 rows/sec., 8.28 B/sec
[5530a9f7ca56] 2024.07.02 12:23:49.001168 [ 726 ] {c290ef2c-2a26-4b9b-94d9-ae495b79076a} executeQuery: Read 34 rows, 719.00 B in 3.027752 sec., 11.229453403052826 rows/sec., 237.47 B/sec.
[5530a9f7ca56] 2024.07.02 12:23:49.001577 [ 726 ] {c290ef2c-2a26-4b9b-94d9-ae495b79076a} TCPHandler: Processed in 3.028892668 sec.
[ccc83b374c0f] 2024.07.02 12:23:51.980030 [ 828 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} MergingSortedTransform: Merge sorted 3 blocks, 5 rows in 6.021000003 sec., 0.830426838981684 rows/sec., 20.76 B/sec
┌─id─┬─name────┬─age─┬─salary─┬─sleep(3)─┐
8. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
└────┴─────────┴─────┴────────┴──────────┘
[ccc83b374c0f] 2024.07.02 12:23:51.983801 [ 828 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} MergingSortedTransform: Merge sorted 3 blocks, 6 rows in 6.023000003 sec., 0.9961813045013209 rows/sec., 25.90 B/sec
[ccc83b374c0f] 2024.07.02 12:23:51.984220 [ 828 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} MergingSortedTransform: Merge sorted 0 blocks, 0 rows in 6.023000003 sec., 0 rows/sec., 0.00 B/sec
[5530a9f7ca56] 2024.07.02 12:23:51.991615 [ 49 ] {a2c4a146-7f4c-4eb6-a592-56f18dce2c19} executeQuery: Read 22 rows, 503.00 B in 3.01439 sec., 7.298325697736524 rows/sec., 166.87 B/sec.
[5530a9f7ca56] 2024.07.02 12:23:51.993096 [ 49 ] {a2c4a146-7f4c-4eb6-a592-56f18dce2c19} TCPHandler: Processed in 3.017691543 sec.
┌─id─┬─name────┬─age─┬─salary─┬─sleep(3)─┐
9. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
10. │ 3 │ Charlie │ 35 │ 80000 │ 0 │
└────┴─────────┴─────┴────────┴──────────┘
[ccc83b374c0f] 2024.07.02 12:23:51.998490 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} executeQuery: Read 190 rows, 4.17 KiB in 6.101148 sec., 31.14168022149274 rows/sec., 699.54 B/sec.
[ccc83b374c0f] 2024.07.02 12:23:52.002682 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} MemoryTracker: Peak memory usage (for query): 3.73 MiB.
[ccc83b374c0f] 2024.07.02 12:23:52.002872 [ 726 ] {e92075fb-1fe8-4762-992c-a5917e8edc9a} TCPHandler: Processed in 6.108239087 sec.

10 rows in set. Elapsed: 6.103 sec.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.