[MDEV-12802] Slow subquery Created: 2017-05-15  Updated: 2017-06-20  Resolved: 2017-06-20

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Subquery
Affects Version/s: 10.1.21, 10.1.22
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Roman Shkola Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: need_feedback, subquery
Environment:

Processor: Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz 2.10GHz
RAM: 32 GB
Operating system: Windows Server 2008 R2 Enterprise
System type: 64-bit


Attachments: PNG File 3214214.png    

 Description   

The following SQL-statement is slow in MariaDB comparing to PostgreSQL and Oracle. I think something is wrong with your optimizer.

select *
from
  (select distinct td.id,
    td.name,
    td.data_type,
    td.data_size,
    td.created_new,
    td.owner_id,
    td.digest,
    td.trainclass,
    td.unit,
    td.instance
  from transferdata td,
    units_unitgroups uu
  where td.trainclass 		= uu.fk_trainclass
  and td.unit 			= uu.fk_unit_number
  and td.data_type_new 	= 19
  and td.created_new 		>= 1490006800000
  and td.trainclass 		= 'myclass'
  and uu.fk_unitgroup_id in (1)
  order by created_new
  ) as subquery
  limit 500

This test has been done in 10 parallel threads with 10 second delay before next 10 threads are started with 3 hour duration.



 Comments   
Comment by Elena Stepanova [ 2017-05-22 ]

Please paste the output of

show create table transferdata;
show create table units_unitgroups;
show index in transferdata;
show index in units_unitgroups;
analyze select *
from
  (select distinct td.id,
    td.name,
    td.data_type,
    td.data_size,
    td.created_new,
    td.owner_id,
    td.digest,
    td.trainclass,
    td.unit,
    td.instance
  from transferdata td,
    units_unitgroups uu
  where td.trainclass     = uu.fk_trainclass
  and td.unit       = uu.fk_unit_number
  and td.data_type_new   = 19
  and td.created_new     >= 1490006800000
  and td.trainclass     = 'myclass'
  and uu.fk_unitgroup_id in (1)
  order by created_new
  ) as subquery
  limit 500;

If possible, please provide the text output rather than screenshot.

Please also attach your cnf file(s).

Comment by Elena Stepanova [ 2017-06-20 ]

Closing for now. If you have further information on this issue, please comment and it will be re-opened.

Generated at Thu Feb 08 08:00:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.