Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant Subquery did not work well in mayBenefitFromIndexForIn #17246

Closed
sundy-li opened this issue Nov 21, 2020 · 1 comment · Fixed by #17249
Closed

Constant Subquery did not work well in mayBenefitFromIndexForIn #17246

sundy-li opened this issue Nov 21, 2020 · 1 comment · Fixed by #17249
Labels
bug Confirmed user-visible misbehaviour in official release

Comments

@sundy-li
Copy link
Contributor

sundy-li commented Nov 21, 2020

Describe the bug

ClickHouse server version 20.12.1 revision 54442.

CREATE TABLE default.data_mt
(
    `key` UInt64,
    `URL` String
)
ENGINE = MergeTree()
ORDER BY key
SETTINGS index_granularity = 8192;

INSERT INTO default.data_mt (key) SELECT number from numbers(100000000);
SELECT count()
FROM data_mt
WHERE key IN 
(
    SELECT toUInt64(number)
    FROM numbers(1)
)

Query id: 54cc915b-1a4d-45fb-8418-e27f4093984b

[ubuntu] 2020.11.21 01:14:48.376249 [ 7979 ] {54cc915b-1a4d-45fb-8418-e27f4093984b} <Debug> executeQuery: (from [::ffff:127.0.0.1]:33982) select count() from data_mt where key in (select toUInt64(number) from numbers(1) )
[ubuntu] 2020.11.21 01:14:48.377420 [ 7979 ] {54cc915b-1a4d-45fb-8418-e27f4093984b} <Debug> default.data_mt (SelectExecutor): Key condition: (column 0 in 1-element set)
[ubuntu] 2020.11.21 01:14:48.377545 [ 7979 ] {54cc915b-1a4d-45fb-8418-e27f4093984b} <Debug> default.data_mt (SelectExecutor): Selected 1 parts by partition key, 1 parts by primary key, 1 marks by primary key, 1 marks to read from 1 ranges
┌─count()─┐
│       1 │
└─────────┘
[ubuntu] 2020.11.21 01:14:48.378924 [ 7979 ] {54cc915b-1a4d-45fb-8418-e27f4093984b} <Information> executeQuery: Read 8192 rows, 64.00 KiB in 0.002556116 sec., 3204862 rows/sec., 24.45 MiB/sec.
[ubuntu] 2020.11.21 01:14:48.379002 [ 7979 ] {54cc915b-1a4d-45fb-8418-e27f4093984b} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.

1 rows in set. Elapsed: 0.004 sec. Processed 8.19 thousand rows, 65.54 KB (2.11 million rows/s., 16.86 MB/s.) 
 select count() from data_mt where key in (select toUInt64(1)  from numbers(1) )

SELECT count()
FROM data_mt
WHERE key IN 
(
    SELECT toUInt64(1)
    FROM numbers(1)
)

Query id: 8b50e72d-e735-4415-b7c6-69d21012ed25

[ubuntu] 2020.11.21 01:15:11.105026 [ 7979 ] {8b50e72d-e735-4415-b7c6-69d21012ed25} <Debug> executeQuery: (from [::ffff:127.0.0.1]:33982) select count() from data_mt where key in (select toUInt64(1) from numbers(1) )
[ubuntu] 2020.11.21 01:15:11.106088 [ 7979 ] {8b50e72d-e735-4415-b7c6-69d21012ed25} <Debug> default.data_mt (SelectExecutor): Key condition: (column 0 in 1-element set)
[ubuntu] 2020.11.21 01:15:11.106186 [ 7979 ] {8b50e72d-e735-4415-b7c6-69d21012ed25} <Debug> default.data_mt (SelectExecutor): Selected 1 parts by partition key, 1 parts by primary key, 12208 marks by primary key, 12208 marks to read from 1 ranges
┌─count()─┐
│       1 │
└─────────┘
[ubuntu] 2020.11.21 01:15:11.233296 [ 7979 ] {8b50e72d-e735-4415-b7c6-69d21012ed25} <Information> executeQuery: Read 100000000 rows, 762.94 MiB in 0.128162804 sec., 780257585 rows/sec., 5.81 GiB/sec.
[ubuntu] 2020.11.21 01:15:11.233371 [ 7979 ] {8b50e72d-e735-4415-b7c6-69d21012ed25} <Debug> MemoryTracker: Peak memory usage (for query): 0.00 B.

1 rows in set. Elapsed: 0.129 sec. Processed 100.00 million rows, 800.00 MB (773.61 million rows/s., 6.19 GB/s.) 

@sundy-li sundy-li added the bug Confirmed user-visible misbehaviour in official release label Nov 21, 2020
@sundy-li sundy-li changed the title Constant Subquery did not work well Constant Subquery did not work well in mayBenefitFromIndexForIn Nov 21, 2020
@sundy-li
Copy link
Contributor Author

cc @amosbird

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant