* from users where name not like 'Ճ౻%' limit 1\G • select * from users where name like 'Ճ౻%' limit 1\G • select * from users where name != 'Ճ౻' limit 1\G • ͜ΕMySQL 5.6Ҏ߱ͩͱ͍͚Δ
• ͜ͷڍಈMySQL͚ͩͬΆ͍ • σϞ • select count(*) from users where phone_num is null\G • select count(*) from slow_users where phone_num is null\G • select count(*) from users where phone_num is not null\G • select count(*) from slow_users where phone_num is not null\G
• select * from users order by order_num limit 1\G • select * from slow_users order by order_num limit 1\G • select * from users where blood_type = 'B' order by birthday limit 1\G • select * from slow_users where blood_type = 'B' order by birthday limit 1\G
σʔλຊମΛݕࡧ͢Δख͕ؒল͔ΕͯߴʹͳΔ • ࢥߟఀࢭͨ͠ঢ়ଶͰORMΛ͏ͱৗʹ SELECT * ʹͳΓɺ͜ͷԸܙ ͕ड͚ΒΕͳ͘ͳΔ • σϞ • select count(*) from users where name = 'Ճ౻ ܙ'\G • select order_num, name from users order by order_num desc limit 1\G
• B: begin; • A: select * from users where id = 123456; • B: select * from users where id = 123456 for update; -- ͜ͷ࣌ͰഉଞϩοΫ • B: update users set order_num = order_num + 1 where id = 123456; • B: select * from users where id = 123456; • A: select * from users where id = 123456; -- ·ͩίϛοτͯ͠ͳ͍͔ΒมΘͬͯͳ͍ • B: commit; • A: select * from users where id = 123456; -- ίϛοτޙ͚ͩͲมΘͬͯͳ͍ • A: select * from users where id = 123456 for update; -- B͕ίϛοτͨ͠ͰऔΕΔ