Closed kawabuchi-tetsuya closed 4 months ago
@ochi-sho-private-study https://github.com/ok-os-job-change-team/tetsuya-twitter-clone-bootcamp/pull/54/commits/4b2cfcc8b2542e9949c65b938e6c48dbc018b72e 変更しました。
MySQL [rails_development]> show index from posts;
+-------+------------+------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
+-------+------------+------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
| posts | 0 | PRIMARY | 1 | id | A | 30 | NULL | NULL | | BTREE | | | YES | NULL |
| posts | 1 | fk_rails_5b5ddfd518 | 1 | user_id | A | 2 | NULL | NULL | | BTREE | | | YES | NULL |
| posts | 1 | index_posts_on_content | 1 | content | A | 30 | NULL | NULL | | BTREE | | | YES | NULL |
| posts | 1 | index_posts_on_title | 1 | title | A | 30 | NULL | NULL | | BTREE | | | YES | NULL |
+-------+------------+------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
MySQL [rails_development]> explain SELECT `posts`.* FROM `posts` WHERE content LIKE 'あ%' UNION SELECT `posts`.* FROM `posts` WHERE title LIKE 'あ%' LIMIT 10;
+----+--------------+------------+------------+-------+------------------------+------------------------+---------+------+------+----------+-----------------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+--------------+------------+------------+-------+------------------------+------------------------+---------+------+------+----------+-----------------------+
| 1 | PRIMARY | posts | NULL | range | index_posts_on_content | index_posts_on_content | 1022 | NULL | 2 | 100.00 | Using index condition |
| 2 | UNION | posts | NULL | range | index_posts_on_title | index_posts_on_title | 1022 | NULL | 2 | 100.00 | Using index condition |
| 3 | UNION RESULT | <union1,2> | NULL | ALL | NULL | NULL | NULL | NULL | NULL | NULL | Using temporary |
+----+--------------+------------+------------+-------+------------------------+------------------------+---------+------+------+----------+-----------------------+
今回対応した issue
やったこと
残りの作業
できるようになること(ユーザ目線)
できなくなること(ユーザ目線)
その他
動作確認
https://github.com/ok-os-job-change-team/tetsuya-twitter-clone-bootcamp/assets/95535099/603c7949-f5a7-4cea-bf5d-f5d9011e9570