ClickHouse: Setting max_result_bytes works incorrectly

Describe what’s wrong

rc1a-ity5agjmuhyu6nu9.mdb.yandexcloud.net :) select version()

SELECT version()

Query id: 8ae63ad5-0d2a-4845-9e1b-1414a19322fb

┌─version()─┐
│ 21.7.11.3 │
└───────────┘

rc1a-ity5agjmuhyu6nu9.mdb.yandexcloud.net :) with timeout as (select commit_sha from checks where check_name='Functional stateless tests (memory)' and check_start_time between '2021-07-07' and '2021-10-07'  group by commit_sha having count() < 10) select count() from checks where commit_sha in timeout and check_name='Functional stateless tests (memory)'

WITH timeout AS
    (
        SELECT commit_sha
        FROM checks
        WHERE (check_name = 'Functional stateless tests (memory)') AND ((check_start_time >= '2021-07-07') AND (check_start_time <= '2021-10-07'))
        GROUP BY commit_sha
        HAVING count() < 10
    )
SELECT count()
FROM checks
WHERE (commit_sha IN (timeout)) AND (check_name = 'Functional stateless tests (memory)')

┌─count()─┐
│     209 │            <-- There are 209 rows
└─────────┘

rc1a-ity5agjmuhyu6nu9.mdb.yandexcloud.net :) with timeout as (select commit_sha from checks where check_name='Functional stateless tests (memory)' and check_start_time between '2021-07-07' and '2021-10-07'  group by commit_sha having count() < 10) select test_name from checks where commit_sha in timeout and check_name='Functional stateless tests (memory)'

WITH timeout AS
    (
        SELECT commit_sha
        FROM checks
        WHERE (check_name = 'Functional stateless tests (memory)') AND ((check_start_time >= '2021-07-07') AND (check_start_time <= '2021-10-07'))
        GROUP BY commit_sha
        HAVING count() < 10
    )
SELECT test_name     -- the only difference, filtering conditions are the same
FROM checks
WHERE (commit_sha IN (timeout)) AND (check_name = 'Functional stateless tests (memory)')
...
<data>
...
49 rows in set. Elapsed: 0.426 sec. Processed 1.83 million rows, 29.65 MB (4.29 million rows/s., 69.63 MB/s.)        <-- it returns only 49 rows (number can be different on different runs)

rc1a-ity5agjmuhyu6nu9.mdb.yandexcloud.net :) with timeout as (select commit_sha from checks where check_name='Functional stateless tests (memory)' and check_start_time between '2021-07-07' and '2021-10-07'  group by commit_sha having count() < 10) select 1 from checks where commit_sha in timeout and check_name='Functional stateless tests (memory)'

WITH timeout AS
    (
        SELECT commit_sha
        FROM checks
        WHERE (check_name = 'Functional stateless tests (memory)') AND ((check_start_time >= '2021-07-07') AND (check_start_time <= '2021-10-07'))
        GROUP BY commit_sha
        HAVING count() < 10
    )
SELECT 1      -- the only differens
FROM checks
WHERE (commit_sha IN (timeout)) AND (check_name = 'Functional stateless tests (memory)')
...
<data>
...

209 rows in set. Elapsed: 0.398 sec. Processed 5.64 million rows, 8.97 MB (14.17 million rows/s., 22.54 MB/s.)        <-- 209 rows as expected

rc1a-ity5agjmuhyu6nu9.mdb.yandexcloud.net :) with timeout as (select commit_sha from checks where check_name='Functional stateless tests (memory)' and check_start_time between '2021-07-07' and '2021-10-07'  group by commit_sha having count() < 10) select test_name from checks where commit_sha in timeout and check_name='Functional stateless tests (memory)' order by test_name

WITH timeout AS
    (
        SELECT commit_sha
        FROM checks
        WHERE (check_name = 'Functional stateless tests (memory)') AND ((check_start_time >= '2021-07-07') AND (check_start_time <= '2021-10-07'))
        GROUP BY commit_sha
        HAVING count() < 10
    )
SELECT test_name
FROM checks
WHERE (commit_sha IN (timeout)) AND (check_name = 'Functional stateless tests (memory)')
ORDER BY test_name ASC
...
<data>
...

209 rows in set. Elapsed: 0.455 sec. Processed 5.64 million rows, 94.27 MB (12.39 million rows/s., 207.27 MB/s.)        <-- 209 rows as expected

Queries with logs: https://gist.githubusercontent.com/tavplubix/e8deba630bdeaa3d55a8c4a1b433d540/raw/21decf09c22f93e0e6813b24c9eef6e0165f352a/gistfile1.txt

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (14 by maintainers)

Most upvoted comments

Looks like no.