回答編集履歴
1
回答を追記
test
CHANGED
@@ -87,3 +87,39 @@
|
|
87
87
|
これでサブクエリを実行しなくて済むようになります。
|
88
88
|
|
89
89
|
あとはKosuke_Shibuya様の回答にあるように適切にインデックスを付けてやれば、十分な性能を得られると思います。
|
90
|
+
|
91
|
+
##### EXPLAIN(インデックス追加後)
|
92
|
+
|
93
|
+
```sql
|
94
|
+
|
95
|
+
CREATE TABLE JK_BASHODATA (
|
96
|
+
|
97
|
+
dataId int not null primary key,
|
98
|
+
|
99
|
+
bashoId int not null,
|
100
|
+
|
101
|
+
itemName varchar(255) not null,
|
102
|
+
|
103
|
+
suryo int not null,
|
104
|
+
|
105
|
+
sakujoFlg boolean not null,
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
index (bashoId),
|
110
|
+
|
111
|
+
index (sakujoFlg)
|
112
|
+
|
113
|
+
);
|
114
|
+
|
115
|
+
```
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
id select_type table type possible_keys key key_len ref rows Extra
|
120
|
+
|
121
|
+
1 SIMPLE B index (null) PRIMARY 4 (null) 3 (null)
|
122
|
+
|
123
|
+
1 SIMPLE D ref bashoId,sakujoFlg bashoId 4 db_9_9c8de.B.bashoId 1 Using where
|
124
|
+
|
125
|
+
```
|