{"id":7323,"date":"2019-08-10T18:01:36","date_gmt":"2019-08-10T09:01:36","guid":{"rendered":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=7323"},"modified":"2019-08-10T18:14:48","modified_gmt":"2019-08-10T09:14:48","slug":"mysql-%e3%81%ae%e7%9c%9f%e5%81%bd%e5%80%a4%e5%9e%8b%e3%81%ae%e3%82%ab%e3%83%a9%e3%83%a0%e3%81%a7%e6%89%8b%e6%8a%9c%e3%81%8d%e3%81%aa%e3%82%af%e3%82%a8%e3%83%aa%e3%82%92%e6%9b%b8%e3%81%8f%e3%81%a8","status":"publish","type":"post","link":"http:\/\/umezawa.dyndns.info\/wordpress\/?p=7323","title":{"rendered":"MySQL \u306e\u771f\u507d\u5024\u578b\u306e\u30ab\u30e9\u30e0\u3067\u624b\u629c\u304d\u306a\u30af\u30a8\u30ea\u3092\u66f8\u304f\u3068\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u3066\u304f\u308c\u306a\u3044"},"content":{"rendered":"<p>\u771f\u507d\u5024\u578b\uff08BIT(1) \u3068\u304b BOOLEAN\uff08TINYINT \u306e\u30a8\u30a4\u30ea\u30a2\u30b9\uff09\u306e\u3053\u3068\uff09\u306e\u30ab\u30e9\u30e0\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u5f35\u3063\u3066\u3082\u3001\u624b\u629c\u304d\u306a SQL \u6587\u3092\u66f8\u304f\u3068\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u3066\u304f\u308c\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<blockquote>\n<pre>\r\nmysql> CREATE TABLE booltest (\r\n    bit1 BIT(1)           NOT NULL,\r\n    tis  TINYINT          NOT NULL,\r\n    tiu  TINYINT UNSIGNED NOT NULL,\r\n    val  INT              NOT NULL,\r\n    INDEX (bit1),\r\n    INDEX (tis),\r\n    INDEX (tiu)\r\n);\r\n\uff08\u7565\uff09\r\n\uff08\u30e9\u30f3\u30c0\u30e0\u306a\u30c7\u30fc\u30bf\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u7684\u306b\u3064\u3063\u3053\u3080\uff09\r\nmysql> EXPLAIN SELECT * FROM BOOLTEST WHERE bit1;\r\n+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+\r\n| id | select_type | table    | partitions | type | possible_keys | key  | key_len | ref  | rows   | filtered | Extra       |\r\n+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+\r\n|  1 | SIMPLE      | booltest | NULL       | ALL  | NULL          | NULL | NULL    | NULL | 998681 |    50.00 | Using where |\r\n+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+\r\nmysql> EXPLAIN SELECT * FROM BOOLTEST WHERE bit1 = true;\r\n+----+-------------+----------+------------+------+---------------+------+---------+-------+--------+----------+-------+\r\n| id | select_type | table    | partitions | type | possible_keys | key  | key_len | ref   | rows   | filtered | Extra |\r\n+----+-------------+----------+------------+------+---------------+------+---------+-------+--------+----------+-------+\r\n|  1 | SIMPLE      | booltest | NULL       | ref  | bit1          | bit1 | 1       | const | 499340 |   100.00 | NULL  |\r\n+----+-------------+----------+------------+------+---------------+------+---------+-------+--------+----------+-------+\r\n<\/pre>\n<\/blockquote>\n<p>bit1 = true \u3068\u66f8\u304b\u306a\u3044\u3068\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u3066\u304f\u308c\u307e\u305b\u3093\u3002TINYINT \u578b\u306b\u3057\u3066\u3042\u308b tis, tiu \u3067\u3082\u540c\u69d8\u3067\u3059\u3002\u666e\u901a\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306a\u3089 bit1 \u304c\u771f\u507d\u5024\u578b\u306a\u3089 bit1 \u3068\u66f8\u3044\u305f\u306e\u3068 bit1 = true \u3068\u6bd4\u8f03\u6f14\u7b97\u3057\u305f\u306e\u3068\u306f\u5168\u304f\u540c\u3058\u3067\u3042\u308b\u306f\u305a\u3067\u3059\u304c\u3001SQL (MySQL) \u3067\u306f\u305d\u3046\u3044\u3046\u6319\u52d5\u306b\u306a\u3063\u3066\u304f\u308c\u306a\u3044\u3088\u3046\u3067\u3059\u3002\u3061\u306a\u307f\u306b EXPLAIN \u3092\u5916\u3057\u3066\u5b9f\u969b\u306b\u30af\u30a8\u30ea\u3057\u3066\u307f\u305f\u5834\u5408\u3001\u51fa\u3066\u304f\u308b\u884c\u306f\u9806\u756a\u3082\u542b\u3081\u3066\u540c\u3058\u3067\u3059\u3002<\/p>\n<p>\u307e\u3042\u3001\u30d7\u30ed\u30b0\u30e9\u30de\u304c\u52dd\u624b\u306b\u771f\u507d\u5024\u578b\u3060\u3068\u601d\u3063\u3066\u308b\u3060\u3051\u3067\u3042\u3063\u3066\u3001 TINYINT \u306f\u6570\u5024\u578b\u3060\u3057 BIT(1) \u306f\u5024\u57df\u304c\u9650\u5b9a\u3055\u308c\u3066\u3044\u308b BINARY \u578b\u3067\u3057\u304b\u306a\u3044\u306a\u306e\u3067\u3001MySQL \u306f\u305d\u3053\u307e\u3067\u6c17\u3092\u52b9\u304b\u305b\u3066\u304f\u308c\u306a\u3044\u306e\u304b\u3082\u3057\u308c\u306a\u3044\u2026<\/p>\n<p>\u4f7f\u3063\u305f\u74b0\u5883:<\/p>\n<ul>\n<li>Ubuntu 18.04 TLS<\/li>\n<li>MySQL 5.7.27<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u771f\u507d\u5024\u578b\uff08BIT(1) \u3068\u304b BOOLEAN\uff08TINYINT \u306e\u30a8\u30a4\u30ea\u30a2\u30b9\uff09\u306e\u3053\u3068\uff09\u306e\u30ab\u30e9\u30e0\u306b\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u5f35\u3063\u3066\u3082\u3001\u624b\u629c\u304d\u306a SQL \u6587\u3092\u66f8\u304f\u3068\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u4f7f\u3063\u3066\u304f\u308c\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-7323","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7323"}],"version-history":[{"count":8,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7323\/revisions"}],"predecessor-version":[{"id":7331,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/7323\/revisions\/7331"}],"wp:attachment":[{"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7323"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/umezawa.dyndns.info\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}