[MDEV-30387] The performance of this sql in high concurrency test is poor Created: 2023-01-12  Updated: 2023-01-12

Status: Open
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.4.25
Fix Version/s: None

Type: Bug Priority: Major
Reporter: s Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Attachments: PNG File image-2023-01-12-10-15-48-401.png     Text File my.cnf.txt     File mysqlslap.sh     File perf.data     PNG File screenshot-1.png     PNG File screenshot-2.png     PNG File screenshot-3.png     PNG File screenshot-4.png     PNG File screenshot-5.png     PNG File screenshot-6.png     Zip Archive strace.zip     File table.sql    

 Description   

os: centos 7.4
cpu: intel xeon 32C
memory: 64G
disk: 1TB ssd
performance test tool: mysqlslap



 Comments   
Comment by s [ 2023-01-12 ]

I do the same test on mysql, the performance is good, but mariadb performance is bad.
when i use a connection to test, the query cost about 0.3s, incresce to 20 connections, the query cost about 10s.

Comment by s [ 2023-01-12 ]

when not run perofrmance, exec query, it cost 0.333s :

Comment by s [ 2023-01-12 ]

when run performance, exec query, it cost 11.753s:
sys cpu high:

Comment by Daniel Black [ 2023-01-12 ]

Which MySQL version was your test comparison?

Can you include EXPLAIN {query on both the MySQL and MariaDB case?

As images I"m having trouble seeing the difference between the two queries. Can you clarify this as text please.

How much of your table matches f_type=3? And f_accessor_id in ...?

What is in ANALYZE FORMAT=JSON query

Comment by s [ 2023-01-12 ]

mysql version: 5.7.25
mariadb version: 10.4.25

two querys is same: select f_doc_id, bit_or(case f_type when 1 then f_perm_value else 0 end) denyvalue, bit_or(case f_type when 2 then f_perm_value else 0 end) allowvalue, bit_or(case f_type when 3 then 1 else 0 end) disable_inherit from t_acs_test where ( f_type=3 or f_accessor_id in ('502af418-a102-11ec-9ba0-965ca20af9fc','c863e4cc-a101-11ec-9ba0-965ca20af9fc','cb18b846-a101-11ec-9ba0-965ca20af9fc','cb756816-a101-11ec-9ba0-965ca20af9fc','cc62c070-a101-11ec-9ba0-965ca20af9fc') ) group by f_doc_id

explain on mariadb:

explain on mysql:

the table size is 102917 rows, the query return about 3w

Comment by s [ 2023-01-12 ]

when not run mysqlslap performance test, analyze format=json result :

when run mysqlslap performance test, analyze format=json result :

Comment by s [ 2023-01-12 ]

table definition:
CREATE TABLE `t_acs_test` (
`f_primary_id` bigint(20) NOT NULL AUTO_INCREMENT,
`f_doc_id` text COLLATE utf8mb4_unicode_ci NOT NULL,
`f_accessor_id` char(40) COLLATE utf8mb4_unicode_ci NOT NULL,
`f_accessor_name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
`f_accessor_type` tinyint(4) NOT NULL,
`f_type` tinyint(4) NOT NULL,
`f_perm_value` int(11) NOT NULL DEFAULT 1,
`f_end_time` bigint(20) DEFAULT -1,
`f_modify_time` bigint(20) NOT NULL DEFAULT 0,
`f_create_time` bigint(20) NOT NULL,
PRIMARY KEY (`f_primary_id`),
KEY `t_perm_f_doc_id_index` (`f_doc_id`(120)),
KEY `t_perm_f_accessor_id_index` (`f_accessor_id`),
KEY `t_perm_f_accessor_type_index` (`f_accessor_type`),
KEY `t_perm_f_type_index` (`f_type`),
KEY `t_perm_f_end_time_index` (`f_end_time`) USING BTREE
) ENGINE=InnoDB

Generated at Thu Feb 08 10:15:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.