Skip to content

[Improve](count on index) improve performance for count on index other than match - #24678

Merged
xiaokang merged 2 commits into
apache:masterfrom
airborne12:count-on-index
Sep 21, 2023
Merged

[Improve](count on index) improve performance for count on index other than match#24678
xiaokang merged 2 commits into
apache:masterfrom
airborne12:count-on-index

Conversation

@airborne12

@airborne12airborne12 commented Sep 20, 2023

Copy link
Copy Markdown
Member

Proposed changes

Issue Number: close #xxx

Related PR: #23276

Test with httplogs dataset, schema as following, we use inverted index for size column:

CREATE TABLE `httplogs` (
`@timestamp` int(11) NULL,
`clientip` varchar(20) NULL,
`request` text NULL,
`status` int(11) NULL,
`size` int(11) NULL,
INDEX size_idx (`size`) USING INVERTED COMMENT ''
) ENGINE=OLAP
DUPLICATE KEY(`@timestamp`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`@timestamp`) BUCKETS 24
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"is_being_synced" = "false",
"storage_format" = "V2",
"compression" = "ZSTD",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false"
);

Total lines for httplogs:

mysql> select COUNT() from httplogs;
+------------+
| count(*) |
+------------+
| 1474712832 |
+------------+
1 row in set (0.18 sec)

before optimization:

mysql> select COUNT(*) from httplogs where size > 20000;
+----------+
| count(*) |
+----------+
| 50533266 |
+----------+
1 row in set (1.22 sec)
mysql> select COUNT(*) from httplogs where size > 20000;
+----------+
| count(*) |
+----------+
| 50533266 |
+----------+
1 row in set (0.45 sec)

after optimization:

mysql> select COUNT(*) from httplogs where size > 20000; +----------+ | count(*) | +----------+ | 50533266 | +----------+
1 row in set (0.64 sec)
mysql> select COUNT(*) from httplogs where size > 20000;
+----------+
| count(*) |
+----------+
| 50533266 |
+----------+
1 row in set (0.20 sec)

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@airborne12

Copy link
Copy Markdown
MemberAuthor

run buildall

@doris-robot

Copy link
Copy Markdown

(From new machine)TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 45.95 seconds
stream load tsv: 596 seconds loaded 74807831229 Bytes, about 119 MB/s
stream load json: 20 seconds loaded 2358488459 Bytes, about 112 MB/s
stream load orc: 64 seconds loaded 1101869774 Bytes, about 16 MB/s
stream load parquet: 32 seconds loaded 861443392 Bytes, about 25 MB/s
insert into select: 28.9 seconds inserted 10000000 Rows, about 346K ops/s
storage size: 17162432122 Bytes

@airborne12

Copy link
Copy Markdown
MemberAuthor

run buildall

@doris-robot

Copy link
Copy Markdown

(From new machine)TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 45.76 seconds
stream load tsv: 604 seconds loaded 74807831229 Bytes, about 118 MB/s
stream load json: 20 seconds loaded 2358488459 Bytes, about 112 MB/s
stream load orc: 64 seconds loaded 1101869774 Bytes, about 16 MB/s
stream load parquet: 32 seconds loaded 861443392 Bytes, about 25 MB/s
insert into select: 29.1 seconds inserted 10000000 Rows, about 343K ops/s
storage size: 17162462872 Bytes

@xiaokangxiaokang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actionsgithub-actionsBot added the approved Indicates a PR has been approved by one committer. label Sep 21, 2023
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@starocean999starocean999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xiaokang
xiaokang merged commit 232226e into apache:masterSep 21, 2023
xiaokang pushed a commit that referenced this pull request Sep 21, 2023
@xiaokangxiaokang mentioned this pull request Sep 30, 2023
@xiaokangxiaokang mentioned this pull request Dec 3, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approvedIndicates a PR has been approved by one committer.dev/2.0.2-mergedreviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@airborne12@doris-robot@xiaokang@starocean999