Page MenuHomePhabricator
Paste P522

Draft query
ActivePublic

Authored by Nikerabbit on Apr 15 2015, 6:34 AM.
Referenced Files
F113075: Draft_query
Apr 15 2015, 6:34 AM
Subscribers
explain SELECT /* ContentTranslation\Translator::getTranslation Nike */ * FROM `bw_cx_translations`,`bw_cx_translators`,`bw_cx_drafts` WHERE translator_translation_id = '135' AND draft_id = '135' AND translator_user_id = '1';
+------+-------------+--------------------+-------+----------------------------+----------------------------+---------+-------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+--------------------+-------+----------------------------+----------------------------+---------+-------------+------+-------------+
| 1 | SIMPLE | bw_cx_translators | const | cx_translation_translators | cx_translation_translators | 8 | const,const | 1 | Using index |
| 1 | SIMPLE | bw_cx_drafts | const | PRIMARY | PRIMARY | 4 | const | 1 | |
| 1 | SIMPLE | bw_cx_translations | ALL | NULL | NULL | NULL | NULL | 27 | |
+------+-------------+--------------------+-------+----------------------------+----------------------------+---------+-------------+------+-------------+
Returns 27 rows due to missing join condition, causing the selected draf_content be duplicated as many times as there are rows in cx_translations.
explain SELECT /* ContentTranslation\Translator::getDraftContent Nike */ draft_content FROM `bw_cx_translators`,`bw_cx_drafts` WHERE translator_user_id = '1' AND translator_translation_id = '135' AND (translator_translation_id = draft_id) LIMIT 1;
+------+-------------+-------------------+-------+----------------------------+----------------------------+---------+-------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+-------------------+-------+----------------------------+----------------------------+---------+-------------+------+-------------+
| 1 | SIMPLE | bw_cx_translators | const | cx_translation_translators | cx_translation_translators | 8 | const,const | 1 | Using index |
| 1 | SIMPLE | bw_cx_drafts | const | PRIMARY | PRIMARY | 4 | const | 1 | |
+------+-------------+-------------------+-------+----------------------------+----------------------------+---------+-------------+------+-------------+
Returns (one field of) 1 row and skips cx_translations completely.

Event Timeline

Nikerabbit changed the title of this paste from untitled to Draft query.
Nikerabbit updated the paste's language from autodetect to autodetect.
Nikerabbit added a project: ContentTranslation.