Bug #42174 | Select count(*) with subquery consuming multi-gigs of memory, 5.0.67 & 4.1.22 | ||
---|---|---|---|
Submitted: | 16 Jan 2009 22:46 | Modified: | 19 Jan 2009 7:06 |
Reporter: | Daniel Smythe | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: General | Severity: | S2 (Serious) |
Version: | 5.0.67 & 4.1.22 | OS: | Linux |
Assigned to: | CPU Architecture: | Any | |
Tags: | count, Memory, memory leak, subqueries |
[16 Jan 2009 22:46]
Daniel Smythe
[17 Jan 2009 13:48]
Valeriy Kravchuk
Thank you for a problem report. Please, send the results of: EXPLAIN SELECT count(*) FROM pligg_pageviews, pligg_links WHERE `pv_type`='story' AND link_id IN( SELECT DISTINCT link_id FROM pligg_links WHERE link_id = pv_page_id)\G from your environment.
[19 Jan 2009 2:16]
Daniel Smythe
Here's the Explain output. It is a considerable number of rows, however still seems out of place to me: mysql> EXPLAIN SELECT count(*) FROM pligg_pageviews,pligg_links WHERE `pv_type`='story' AND link_id IN(SELECT DISTINCT link_id FROM pligg_links WHERE link_id=pv_page_id); +----+--------------------+-----------------+--------+---------------+---------+---------+------------------------------------+-------+-------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------------+-----------------+--------+---------------+---------+---------+------------------------------------+-------+-------------------------------------------+ | 1 | PRIMARY | pligg_pageviews | ref | pv_type | pv_type | 1 | const | 11359 | Using where; Using index | | 1 | PRIMARY | pligg_links | index | NULL | PRIMARY | 4 | NULL | 1480 | Using where; Using index | | 2 | DEPENDENT SUBQUERY | pligg_links | eq_ref | PRIMARY | PRIMARY | 4 | newsurl.pligg_pageviews.pv_page_id | 1 | Using where; Using index; Using temporary | +----+--------------------+-----------------+--------+---------------+---------+---------+------------------------------------+-------+-------------------------------------------+ 3 rows in set (0.00 sec) mysql> select 11357*1480; +------------+ | 11357*1480 | +------------+ | 16808360 | +------------+ 1 row in set (0.00 sec) We're still only talking about 3MB of data or so. mysql> show table status like 'pligg_links'; +-------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | +-------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | pligg_links | MyISAM | 9 | Dynamic | 1480 | 1364 | 2019200 | 4294967295 | 3322880 | 0 | 1481 | 2008-10-22 02:29:21 | 2009-01-16 09:18:32 | NULL | utf8_general_ci | NULL | | | +-------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ 1 row in set (0.00 sec) mysql> show table status like 'pligg_pageviews'; +-----------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | +-----------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | pligg_pageviews | MyISAM | 9 | Dynamic | 26262 | 33 | 874184 | 4294967295 | 630784 | 0 | 26263 | 2008-10-22 02:29:21 | 2009-01-16 10:40:12 | NULL | utf8_general_ci | NULL | | | +-----------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ 1 row in set (0.00 sec)
[19 Jan 2009 2:22]
Daniel Smythe
And also, the specific binaries we are using - perhaps using x86_64 binaries is part of the issue: mysql-max-4.1.22-unknown-linux-gnu-x86_64-glibc23 mysql-5.0.67-linux-x86_64-glibc23
[19 Jan 2009 7:06]
Sveta Smirnova
This is duplicate of bug #42037