Bug #40576 | query that run forever, gives expect results adding some fields in select stat. | ||
---|---|---|---|
Submitted: | 7 Nov 2008 13:06 | Modified: | 9 Jan 2009 8:22 |
Reporter: | nicola tesser | Email Updates: | |
Status: | No Feedback | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | Ver 14.12 Distrib 5.0.51a, for debian-li | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | SQL |
[7 Nov 2008 13:06]
nicola tesser
[7 Nov 2008 15:18]
Valeriy Kravchuk
Thank you for a problem report. Please, send the results of EXPLAIN for both "good" and "bad" queries.
[7 Nov 2008 15:38]
nicola tesser
####bad query SELECT p.id as person_id,o.id as organization_id,r.id as relation_id FROM people p, organizations o, relations r WHERE ((r.investment_id = o.id AND r.investor_id = p.id) OR (r.employer_id = o.id AND r.employee_id = p.id)) #####explain: +----+-------------+-------+-------+-----------------------------------------------------------------------------------------------------------------------------+---------+---------+------+------+------------------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+-----------------------------------------------------------------------------------------------------------------------------+---------+---------+------+------+------------------------------------------------------+ | 1 | SIMPLE | o | index | PRIMARY | PRIMARY | 4 | NULL | 3983 | Using index | | 1 | SIMPLE | p | index | PRIMARY | PRIMARY | 4 | NULL | 4492 | Using index | | 1 | SIMPLE | r | ALL | relation_employee,relation_employer,relation_investment,relation_investor,investment_id,investor_id,employee_id,employer_id | NULL | NULL | NULL | 7308 | Range checked for each record (index map: 0x78000F0) | +----+-------------+-------+-------+-----------------------------------------------------------------------------------------------------------------------------+---------+---------+------+------+------------------------------------------------------+ #####good query SELECT firstname,p.id as person_id,o.id as organization_id,r.id as relation_id FROM people p, organizations o, relations r WHERE ((r.investment_id = o.id AND r.investor_id = p.id) OR (r.employer_id = o.id AND r.employee_id = p.id)) #####explain: +----+-------------+-------+-------+-----------------------------------------------------------------+---------+---------+------+------+------------------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+-----------------------------------------------------------------+---------+---------+------+------+------------------------------------------------------+ | 1 | SIMPLE | o | index | PRIMARY | PRIMARY | 4 | NULL | 3983 | Using index | | 1 | SIMPLE | r | ALL | relation_employer,relation_investment,investment_id,employer_id | NULL | NULL | NULL | 7308 | Range checked for each record (index map: 0x4800060) | | 1 | SIMPLE | p | ALL | PRIMARY | NULL | NULL | NULL | 4492 | Range checked for each record (index map: 0x1) | +----+-------------+-------+-------+-----------------------------------------------------------------+---------+---------+------+------+------------------------------------------------------+
[9 Dec 2008 8:22]
Valeriy Kravchuk
Please, try to repeat with a newer version, 5.0.67. In case of the same problem, please, upload a compressed dump of tables used, if possible.
[10 Jan 2009 0:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".