My hoster is telling me that the query below is processing 52 million records every time it's run. Any ideas on where this query is, what it does or how to fix it would very much be appreciated. I have not changed anything in the installation in forever. The host thinks that the more content I write, somehow the query was pushed over the limit for warnings.
QUERY:
SELECT n.nid, n.type, n.status, n.promote, n.changed, u.dst FROM node n LEFT JOIN url_alias u ON u.src=CONCAT('node/',n.nid)
EXPLAIN:
explain SELECT n.nid, n.type, n.status, n.promote, n.changed, u.dst FROM node n LEFT JOIN url_alias u ON u.src=CONCAT('node/',n.nid)\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: n type: ALL possible_keys: NULL key: NULL key_len: NULL ref: NULL rows: 3971 Extra: *************************** 2. row *************************** id: 1 select_type: SIMPLE table: u type: ALL possible_keys: src key: NULL key_len: NULL ref: NULL rows: 15110 Extra: 2 rows in set (0.00 sec)
Other Info:
Time: 081028 16:01:51 # User@Host: root[root] @ [127.0.0.1] # Query_time: 53 Lock_time: 0 Rows_sent: 1644 Rows_examined: 22021902 use 351357_drupal5; SELECT n.nid, n.type, n.status, n.promote, n.changed, u.dst FROM node n LEFT JOIN url_alias u ON u.src=CONCAT('node/',n.nid);
Thanks in advance.
Comments
bump for evening :)
bump for evening :)
i could really use some help
i could really use some help here plz
More information
I don't have the solution, but I do have some more information on what is happening.
The select statement is missing a clause that associates some part of the url_alias table to the node table after the 'ON'. After the association has been made, there needs to be a where statement. Being it is missing this, instead of joining a few hundred/thousand rows... it is joining every row.... performing a Cartesian Join... so for every row in one table it examines all rows in the other (3,971x15,110=60,001,810).
Anyone know what exactly this SELECT statement is for or where it is located? It may be dynamically created. I hope this helps!
thank you for your reply - i
thank you for your reply - i got some additional help on the drupal mailing list - they told me to upgrade the url alias module - i did that and will wait to see if my host complains more :)