提交 98ca4a1d 编写于 作者: martianzhang's avatar martianzhang

add mysql environment verbose info

上级 faaa59f6
......@@ -1405,7 +1405,7 @@ func FormatSuggest(sql string, format string, suggests ...map[string]Rule) (map[
}
sort.Strings(sortedHeuristicSuggest)
for _, item := range sortedHeuristicSuggest {
buf = append(buf, fmt.Sprintln("## ", suggest[item].Summary))
buf = append(buf, fmt.Sprintln("##", suggest[item].Summary))
if item == "OK" {
continue
}
......
......@@ -46,7 +46,7 @@ SELECT country_id, last_update FROM city NATURAL LEFT JOIN country;
SELECT country_id, last_update FROM city NATURAL RIGHT JOIN country;
SELECT a.country_id, a.last_update FROM city a STRAIGHT_JOIN country b ON a.country_id=b.country_id;
SELECT a.address, a.postal_code FROM sakila.address a WHERE a.city_id IN (SELECT c.city_id FROM sakila.city c);
SELECT visitor_id, url FROM (SELECT id FROM log WHERE ip="123.45.67.89" order by ts desc limit 50, 10) I JOIN log ON (I.id=log.id) JOIN url ON (url.id=log.url_id) order by TS desc;
SELECT city FROM( SELECT city_id FROM city WHERE city = "A Corua (La Corua)" ORDER BY last_update DESC LIMIT 50, 10) I JOIN city ON (I.city_id = city.city_id) JOIN country ON (country.country_id = city.country_id) ORDER BY city DESC;
DELETE city, country FROM city INNER JOIN country using (country_id) WHERE city.city_id = 1;
DELETE city FROM city LEFT JOIN country ON city.country_id = country.country_id WHERE country.country IS NULL;
DELETE a1, a2 FROM city AS a1 INNER JOIN country AS a2 WHERE a1.country_id=a2.country_id;
......@@ -79,7 +79,7 @@ SELECT description FROM film WHERE description IN('NEWS','asd') GROUP BY descrip
alter table address add index idx_city_id(city_id);
alter table inventory add index `idx_store_film` (`store_id`,`film_id`);
alter table inventory add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`);
SELECT DATE_FORMAT(t.atm, '%Y-%m-%d'), COUNT(DISTINCT (t.usr)) FROM usr_terminal t WHERE t.atm > '2018-10-22 00:00:00' AND t.agent LIKE '%Chrome%' AND t.system = 'eip' GROUP BY DATE_FORMAT(t.atm, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.atm, '%Y-%m-%d');
SELECT DATE_FORMAT(t.last_update, '%Y-%m-%d'), COUNT(DISTINCT (t.city)) FROM city t WHERE t.last_update > '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city = 'eip' GROUP BY DATE_FORMAT(t.last_update, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update, '%Y-%m-%d');
create table hello.t (id int unsigned);
select * from tb where data >= '';
alter table tb alter column id drop default;
......@@ -94,8 +94,8 @@ SELECT a.country_id, a.last_update FROM city a STRAIGHT_JOIN country b ON a.coun
SELECT a.country_id, a.last_update FROM city a STRAIGHT_JOIN country b ON a.country_id=b.country_id;
SELECT a.address, a.postal_code FROM sakila.address a WHERE a.city_id IN (SELECT c.city_id FROM sakila.city c);
SELECT a.address, a.postal_code FROM sakila.address a WHERE a.city_id IN (SELECT c.city_id FROM sakila.city c);
SELECT visitor_id, url FROM (SELECT id FROM log WHERE ip="123.45.67.89" order by ts desc limit 50, 10) I JOIN log ON (I.id=log.id) JOIN url ON (url.id=log.url_id) order by TS desc;
SELECT visitor_id, url FROM (SELECT id FROM log WHERE ip="123.45.67.89" order by ts desc limit 50, 10) I JOIN log ON (I.id=log.id) JOIN url ON (url.id=log.url_id) order by TS desc;
SELECT city FROM( SELECT city_id FROM city WHERE city = "A Corua (La Corua)" ORDER BY last_update DESC LIMIT 50, 10) I JOIN city ON (I.city_id = city.city_id) JOIN country ON (country.country_id = city.country_id) ORDER BY city DESC;
SELECT city FROM( SELECT city_id FROM city WHERE city = "A Corua (La Corua)" ORDER BY last_update DESC LIMIT 50, 10) I JOIN city ON (I.city_id = city.city_id) JOIN country ON (country.country_id = city.country_id) ORDER BY city DESC;
DELETE city, country FROM city INNER JOIN country using (country_id) WHERE city.city_id = 1;
DELETE city, country FROM city INNER JOIN country using (country_id) WHERE city.city_id = 1;
DELETE city FROM city LEFT JOIN country ON city.country_id = country.country_id WHERE country.country IS NULL;
......@@ -160,8 +160,8 @@ alter table inventory add index `idx_store_film` (`store_id`,`film_id`);
alter table inventory add index `idx_store_film` (`store_id`,`film_id`);
alter table inventory add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`);
alter table inventory add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`);
SELECT DATE_FORMAT(t.atm, '%Y-%m-%d'), COUNT(DISTINCT (t.usr)) FROM usr_terminal t WHERE t.atm > '2018-10-22 00:00:00' AND t.agent LIKE '%Chrome%' AND t.system = 'eip' GROUP BY DATE_FORMAT(t.atm, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.atm, '%Y-%m-%d');
SELECT DATE_FORMAT(t.atm, '%Y-%m-%d'), COUNT(DISTINCT (t.usr)) FROM usr_terminal t WHERE t.atm > '2018-10-22 00:00:00' AND t.agent LIKE '%Chrome%' AND t.system = 'eip' GROUP BY DATE_FORMAT(t.atm, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.atm, '%Y-%m-%d');
SELECT DATE_FORMAT(t.last_update, '%Y-%m-%d'), COUNT(DISTINCT (t.city)) FROM city t WHERE t.last_update > '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city = 'eip' GROUP BY DATE_FORMAT(t.last_update, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update, '%Y-%m-%d');
SELECT DATE_FORMAT(t.last_update, '%Y-%m-%d'), COUNT(DISTINCT (t.city)) FROM city t WHERE t.last_update > '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city = 'eip' GROUP BY DATE_FORMAT(t.last_update, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update, '%Y-%m-%d');
create table hello.t (id int unsigned);
create table hello.t (id int unsigned);
select * from tb where data >= '';
......
......@@ -456,26 +456,25 @@ SELECT
c. city_id
FROM
sakila. city c);
SELECT visitor_id, url FROM (SELECT id FROM log WHERE ip="123.45.67.89" order by ts desc limit 50, 10) I JOIN log ON (I.id=log.id) JOIN url ON (url.id=log.url_id) order by TS desc;
SELECT city FROM( SELECT city_id FROM city WHERE city = "A Corua (La Corua)" ORDER BY last_update DESC LIMIT 50, 10) I JOIN city ON (I.city_id = city.city_id) JOIN country ON (country.country_id = city.country_id) ORDER BY city DESC;
SELECT
visitor_id, url
FROM
(
city
FROM(
SELECT
id
city_id
FROM
LOG
city
WHERE
ip= "123.45.67.89"
city = "A Corua (La Corua)"
ORDER BY
ts desc
last_update DESC
LIMIT
50, 10) I
JOIN LOG ON (I. id= LOG. id)
JOIN url ON (url. id= LOG. url_id)
JOIN city ON (I. city_id = city. city_id)
JOIN country ON (country. country_id = city. country_id)
ORDER BY
TS desc;
city DESC;
DELETE city, country FROM city INNER JOIN country using (country_id) WHERE city.city_id = 1;
DELETE city, country
FROM
......@@ -846,24 +845,24 @@ ADD
ADD
index `idx_store_film` (
`store_id`, `film_id`);
SELECT DATE_FORMAT(t.atm, '%Y-%m-%d'), COUNT(DISTINCT (t.usr)) FROM usr_terminal t WHERE t.atm > '2018-10-22 00:00:00' AND t.agent LIKE '%Chrome%' AND t.system = 'eip' GROUP BY DATE_FORMAT(t.atm, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.atm, '%Y-%m-%d');
SELECT DATE_FORMAT(t.last_update, '%Y-%m-%d'), COUNT(DISTINCT (t.city)) FROM city t WHERE t.last_update > '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city = 'eip' GROUP BY DATE_FORMAT(t.last_update, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update, '%Y-%m-%d');
SELECT
DATE_FORMAT( t. atm, '%Y-%m-%d'
DATE_FORMAT( t. last_update, '%Y-%m-%d'
),
COUNT( DISTINCT (
t. usr))
t. city))
FROM
usr_terminal t
city t
WHERE
t. atm > '2018-10-22 00:00:00'
AND t. agent LIKE '%Chrome%'
AND t. system = 'eip'
t. last_update > '2018-10-22 00:00:00'
AND t. city LIKE '%Chrome%'
AND t. city = 'eip'
GROUP BY
DATE_FORMAT( t. atm, '%Y-%m-%d'
DATE_FORMAT( t. last_update, '%Y-%m-%d'
)
ORDER BY
DATE_FORMAT( t. atm, '%Y-%m-%d'
DATE_FORMAT( t. last_update, '%Y-%m-%d'
);
create table hello.t (id int unsigned);
create table hello. t (id int unsigned);
......
[
{
"text": "select 1",
"resultFields": null,
"SQLCache": true,
"CalcFoundRows": false,
"StraightJoin": false,
......@@ -8,11 +10,14 @@
"From": null,
"Where": null,
"Fields": {
"text": "",
"Fields": [
{
"text": "1",
"Offset": 7,
"WildCard": null,
"Expr": {
"text": "",
"Type": {
"Tp": 8,
"Flag": 128,
......@@ -21,7 +26,16 @@
"Charset": "binary",
"Collate": "binary",
"Elems": null
}
},
"flag": 0,
"k": 1,
"collation": 0,
"decimal": 0,
"length": 0,
"i": 1,
"b": null,
"x": null,
"projectionOffset": -1
},
"AsName": {
"O": "",
......
......@@ -94,8 +94,8 @@ SELECT a.country_id, a.last_update FROM city a STRAIGHT_JOIN country b ON a.coun
[{5 SELECT 0} {1 a. 0} {1 country_id, 0} {0 0} {1 a. 0} {1 last_update 0} {5 FROM 0} {1 city 0} {1 a 0} {1 STRAIGHT_JOIN 0} {1 country 0} {1 b 0} {1 ON 0} {1 a. 0} {1 country_id= 0} {1 b. 0} {1 country_id; 0}]
SELECT a.address, a.postal_code FROM sakila.address a WHERE a.city_id IN (SELECT c.city_id FROM sakila.city c);
[{5 SELECT 0} {1 a. 0} {1 address, 0} {0 0} {1 a. 0} {1 postal_code 0} {5 FROM 0} {1 sakila. 0} {1 address 0} {1 a 0} {5 WHERE 0} {1 a. 0} {1 city_id 0} {1 IN 0} {0 0} {7 ( 0} {5 SELECT 0} {1 c. 0} {1 city_id 0} {5 FROM 0} {1 sakila. 0} {1 city 0} {1 c) 0} {7 ; 0}]
SELECT visitor_id, url FROM (SELECT id FROM log WHERE ip="123.45.67.89" order by ts desc limit 50, 10) I JOIN log ON (I.id=log.id) JOIN url ON (url.id=log.url_id) order by TS desc;
[{5 SELECT 0} {1 visitor_id, 0} {0 0} {1 url 0} {5 FROM 0} {7 ( 0} {5 SELECT 0} {1 id 0} {5 FROM 0} {4 LOG 0} {5 WHERE 0} {1 ip= 0} {2 "123.45.67.89" 0} {0 0} {5 ORDER BY 0} {1 ts 0} {1 desc 0} {5 LIMIT 0} {10 50, 0} {0 0} {10 10) 0} {0 0} {1 I 0} {6 JOIN 0} {4 LOG 0} {1 ON 0} {7 ( 0} {1 I. 0} {1 id= 0} {4 LOG. 0} {1 id) 0} {0 0} {6 JOIN 0} {1 url 0} {1 ON 0} {7 ( 0} {1 url. 0} {1 id= 0} {4 LOG. 0} {1 url_id) 0} {0 0} {5 ORDER BY 0} {1 TS 0} {1 desc; 0}]
SELECT city FROM( SELECT city_id FROM city WHERE city = "A Corua (La Corua)" ORDER BY last_update DESC LIMIT 50, 10) I JOIN city ON (I.city_id = city.city_id) JOIN country ON (country.country_id = city.country_id) ORDER BY city DESC;
[{5 SELECT 0} {1 city 0} {5 FROM( 0} {0 0} {5 SELECT 0} {1 city_id 0} {5 FROM 0} {1 city 0} {5 WHERE 0} {1 city 0} {7 = 0} {0 0} {2 "A Corua (La Corua)" 0} {0 0} {5 ORDER BY 0} {1 last_update 0} {1 DESC 0} {5 LIMIT 0} {10 50, 0} {0 0} {10 10) 0} {0 0} {1 I 0} {6 JOIN 0} {1 city 0} {1 ON 0} {7 ( 0} {1 I. 0} {1 city_id 0} {7 = 0} {0 0} {1 city. 0} {1 city_id) 0} {0 0} {6 JOIN 0} {1 country 0} {1 ON 0} {7 ( 0} {1 country. 0} {1 country_id 0} {7 = 0} {0 0} {1 city. 0} {1 country_id) 0} {0 0} {5 ORDER BY 0} {1 city 0} {1 DESC; 0}]
DELETE city, country FROM city INNER JOIN country using (country_id) WHERE city.city_id = 1;
[{1 DELETE 0} {1 city, 0} {0 0} {1 country 0} {5 FROM 0} {1 city 0} {6 INNER JOIN 0} {1 country 0} {1 using 0} {7 ( 0} {1 country_id) 0} {0 0} {5 WHERE 0} {1 city. 0} {1 city_id 0} {7 = 0} {0 0} {10 1; 0}]
DELETE city FROM city LEFT JOIN country ON city.country_id = country.country_id WHERE country.country IS NULL;
......@@ -160,8 +160,8 @@ alter table inventory add index `idx_store_film` (`store_id`,`film_id`);
[{5 ALTER TABLE 0} {1 inventory 0} {5 ADD 0} {1 index 0} {3 `idx_store_film` 0} {0 0} {7 ( 0} {3 `store_id` 0} {7 , 0} {3 `film_id` 0} {7 ) 0} {7 ; 0}]
alter table inventory add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`),add index `idx_store_film` (`store_id`,`film_id`);
[{5 ALTER TABLE 0} {1 inventory 0} {5 ADD 0} {1 index 0} {3 `idx_store_film` 0} {0 0} {7 ( 0} {3 `store_id` 0} {7 , 0} {3 `film_id` 0} {7 ) 0} {7 , 0} {5 ADD 0} {1 index 0} {3 `idx_store_film` 0} {0 0} {7 ( 0} {3 `store_id` 0} {7 , 0} {3 `film_id` 0} {7 ) 0} {7 , 0} {5 ADD 0} {1 index 0} {3 `idx_store_film` 0} {0 0} {7 ( 0} {3 `store_id` 0} {7 , 0} {3 `film_id` 0} {7 ) 0} {7 ; 0}]
SELECT DATE_FORMAT(t.atm, '%Y-%m-%d'), COUNT(DISTINCT (t.usr)) FROM usr_terminal t WHERE t.atm > '2018-10-22 00:00:00' AND t.agent LIKE '%Chrome%' AND t.system = 'eip' GROUP BY DATE_FORMAT(t.atm, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.atm, '%Y-%m-%d');
[{5 SELECT 0} {4 DATE_FORMAT( 0} {1 t. 0} {1 atm, 0} {0 0} {2 '%Y-%m-%d' 0} {7 ) 0} {7 , 0} {0 0} {4 COUNT( 0} {1 DISTINCT 0} {7 ( 0} {1 t. 0} {1 usr) 0} {7 ) 0} {0 0} {5 FROM 0} {1 usr_terminal 0} {1 t 0} {5 WHERE 0} {1 t. 0} {1 atm 0} {7 > 0} {0 0} {2 '2018-10-22 00:00:00' 0} {0 0} {6 AND 0} {1 t. 0} {1 agent 0} {1 LIKE 0} {2 '%Chrome%' 0} {0 0} {6 AND 0} {1 t. 0} {1 system 0} {7 = 0} {0 0} {2 'eip' 0} {0 0} {5 GROUP BY 0} {4 DATE_FORMAT( 0} {1 t. 0} {1 atm, 0} {0 0} {2 '%Y-%m-%d' 0} {7 ) 0} {0 0} {5 ORDER BY 0} {4 DATE_FORMAT( 0} {1 t. 0} {1 atm, 0} {0 0} {2 '%Y-%m-%d' 0} {7 ) 0} {7 ; 0}]
SELECT DATE_FORMAT(t.last_update, '%Y-%m-%d'), COUNT(DISTINCT (t.city)) FROM city t WHERE t.last_update > '2018-10-22 00:00:00' AND t.city LIKE '%Chrome%' AND t.city = 'eip' GROUP BY DATE_FORMAT(t.last_update, '%Y-%m-%d') ORDER BY DATE_FORMAT(t.last_update, '%Y-%m-%d');
[{5 SELECT 0} {4 DATE_FORMAT( 0} {1 t. 0} {1 last_update, 0} {0 0} {2 '%Y-%m-%d' 0} {7 ) 0} {7 , 0} {0 0} {4 COUNT( 0} {1 DISTINCT 0} {7 ( 0} {1 t. 0} {1 city) 0} {7 ) 0} {0 0} {5 FROM 0} {1 city 0} {1 t 0} {5 WHERE 0} {1 t. 0} {1 last_update 0} {7 > 0} {0 0} {2 '2018-10-22 00:00:00' 0} {0 0} {6 AND 0} {1 t. 0} {1 city 0} {1 LIKE 0} {2 '%Chrome%' 0} {0 0} {6 AND 0} {1 t. 0} {1 city 0} {7 = 0} {0 0} {2 'eip' 0} {0 0} {5 GROUP BY 0} {4 DATE_FORMAT( 0} {1 t. 0} {1 last_update, 0} {0 0} {2 '%Y-%m-%d' 0} {7 ) 0} {0 0} {5 ORDER BY 0} {4 DATE_FORMAT( 0} {1 t. 0} {1 last_update, 0} {0 0} {2 '%Y-%m-%d' 0} {7 ) 0} {7 ; 0}]
create table hello.t (id int unsigned);
[{1 create 0} {1 table 0} {1 hello. 0} {1 t 0} {7 ( 0} {1 id 0} {1 int 0} {1 unsigned) 0} {7 ; 0}]
select * from tb where data >= '';
......
......@@ -425,8 +425,5 @@ func main() {
return
}
// syntax check verbose mode, add output for success!
if common.Config.OnlySyntaxCheck && common.Config.Verbose {
fmt.Println("Syntax check OK!")
}
verboseInfo()
}
......@@ -153,3 +153,33 @@ func Test_Main_helpTools(t *testing.T) {
common.Config.ListReportTypes = orgConfig
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
}
func Test_Main_verboseInfo(t *testing.T) {
common.Log.Debug("Entering function: %s", common.GetFunctionName())
orgVerbose := common.Config.Verbose
common.Config.Verbose = true
err := common.GoldenDiff(func() {
// Syntax check OK
orgSyntaxCheck := common.Config.OnlySyntaxCheck
common.Config.OnlySyntaxCheck = true
verboseInfo()
common.Config.OnlySyntaxCheck = orgSyntaxCheck
// MySQL environment verbose info
orgTestDSNDisable := common.Config.TestDSN.Disable
common.Config.TestDSN.Disable = true
verboseInfo()
common.Config.TestDSN.Disable = orgTestDSNDisable
orgOnlineDSNDisable := common.Config.OnlineDSN.Disable
common.Config.OnlineDSN.Disable = true
verboseInfo()
common.Config.OnlineDSN.Disable = orgOnlineDSNDisable
}, t.Name(), update)
if err != nil {
t.Error(err)
}
common.Config.Verbose = orgVerbose
common.Log.Debug("Exiting function: %s", common.GetFunctionName())
}
Syntax check OK!
MySQL environment verbose info
* test-dsn: 127.0.0.1:3306 is disable, please check log.
MySQL environment verbose info
* online-dsn: 127.0.0.1:3306 is disable, please check log.
......@@ -237,3 +237,28 @@ func shutdown(vEnv *env.VirtualEnv, rEnv *database.Connector) {
common.LogIfWarn(err, "")
os.Exit(0)
}
func verboseInfo() {
if !common.Config.Verbose {
return
}
// syntax check verbose mode, add output for success!
if common.Config.OnlySyntaxCheck {
fmt.Println("Syntax check OK!")
return
}
switch common.Config.ReportType {
case "markdown":
if common.Config.TestDSN.Disable || common.Config.OnlineDSN.Disable {
fmt.Println("MySQL environment verbose info")
// TestDSN
if common.Config.TestDSN.Disable {
fmt.Println("* test-dsn:", common.Config.TestDSN.Addr, "is disable, please check log.")
}
// OnlineDSN
if common.Config.OnlineDSN.Disable {
fmt.Println("* online-dsn:", common.Config.OnlineDSN.Addr, "is disable, please check log.")
}
}
}
}
online-dsn:
user: root
password: '********'
net: tcp
addr: 127.0.0.1:3306
schema: sakila
user: root
password: '********'
charset: utf8mb4
disable: false
charset: utf8
collation: utf8_general_ci
loc: UTC
tls: ""
server-public-key: ""
maxallowedpacket: 4194304
params:
charset: utf8
timeout: 0
read-timeout: 0
write-timeout: 0
allow-native-passwords: true
allow-old-passwords: false
disable: false
test-dsn:
user: root
password: '********'
net: tcp
addr: 127.0.0.1:3306
schema: sakila
user: root
password: '********'
charset: utf8mb4
disable: false
charset: utf8
collation: utf8_general_ci
loc: UTC
tls: ""
server-public-key: ""
maxallowedpacket: 4194304
params:
charset: utf8
timeout: 0
read-timeout: 0
write-timeout: 0
allow-native-passwords: true
allow-old-passwords: false
disable: false
allow-online-as-test: true
drop-test-temporary: true
cleanup-test-database: false
......
char(10) cp1250 10
char(256) cp1250 255
binary(10) cp1250 10
binary(256) cp1250 255
varchar(10) cp1250 11
varbinary(10) cp1250 11
enum('G','PG','PG-13','R','NC-17') cp1250 1
set('one', 'two') cp1250 1
not_exist cp1250 0
char(10) cp932 20
char(256) cp932 510
binary(10) cp932 10
binary(256) cp932 255
varchar(10) cp932 21
varbinary(10) cp932 21
enum('G','PG','PG-13','R','NC-17') cp932 1
set('one', 'two') cp932 1
not_exist cp932 0
char(10) gb2312 20
char(256) gb2312 510
binary(10) gb2312 10
binary(256) gb2312 255
varchar(10) gb2312 21
varbinary(10) gb2312 21
enum('G','PG','PG-13','R','NC-17') gb2312 1
set('one', 'two') gb2312 1
not_exist gb2312 0
char(10) latin1 10
char(256) latin1 255
binary(10) latin1 10
binary(256) latin1 255
varchar(10) latin1 11
varbinary(10) latin1 11
enum('G','PG','PG-13','R','NC-17') latin1 1
set('one', 'two') latin1 1
not_exist latin1 0
char(10) utf32 40
char(256) utf32 1020
binary(10) utf32 10
binary(256) utf32 255
varchar(10) utf32 41
varbinary(10) utf32 41
enum('G','PG','PG-13','R','NC-17') utf32 1
set('one', 'two') utf32 1
not_exist utf32 0
char(10) latin5 10
char(256) latin5 255
binary(10) latin5 10
binary(256) latin5 255
varchar(10) latin5 11
varbinary(10) latin5 11
enum('G','PG','PG-13','R','NC-17') latin5 1
set('one', 'two') latin5 1
not_exist latin5 0
char(10) latin7 10
char(256) latin7 255
binary(10) latin7 10
......@@ -61,24 +7,107 @@ varbinary(10) latin7 11
enum('G','PG','PG-13','R','NC-17') latin7 1
set('one', 'two') latin7 1
not_exist latin7 0
char(10) big5 20
char(256) big5 510
binary(10) big5 10
binary(256) big5 255
varchar(10) big5 21
varbinary(10) big5 21
enum('G','PG','PG-13','R','NC-17') big5 1
set('one', 'two') big5 1
not_exist big5 0
char(10) cp1257 10
char(256) cp1257 255
binary(10) cp1257 10
binary(256) cp1257 255
varchar(10) cp1257 11
varbinary(10) cp1257 11
enum('G','PG','PG-13','R','NC-17') cp1257 1
set('one', 'two') cp1257 1
not_exist cp1257 0
char(-1) latin7 0
char(10) ujis 30
char(256) ujis 765
binary(10) ujis 10
binary(256) ujis 255
varchar(10) ujis 31
varbinary(10) ujis 31
enum('G','PG','PG-13','R','NC-17') ujis 1
set('one', 'two') ujis 1
not_exist ujis 0
char(-1) ujis 0
char(10) cp1256 10
char(256) cp1256 255
binary(10) cp1256 10
binary(256) cp1256 255
varchar(10) cp1256 11
varbinary(10) cp1256 11
enum('G','PG','PG-13','R','NC-17') cp1256 1
set('one', 'two') cp1256 1
not_exist cp1256 0
char(-1) cp1256 0
char(10) cp852 10
char(256) cp852 255
binary(10) cp852 10
binary(256) cp852 255
varchar(10) cp852 11
varbinary(10) cp852 11
enum('G','PG','PG-13','R','NC-17') cp852 1
set('one', 'two') cp852 1
not_exist cp852 0
char(-1) cp852 0
char(10) cp866 10
char(256) cp866 255
binary(10) cp866 10
binary(256) cp866 255
varchar(10) cp866 11
varbinary(10) cp866 11
enum('G','PG','PG-13','R','NC-17') cp866 1
set('one', 'two') cp866 1
not_exist cp866 0
char(-1) cp866 0
char(10) geostd8 10
char(256) geostd8 255
binary(10) geostd8 10
binary(256) geostd8 255
varchar(10) geostd8 11
varbinary(10) geostd8 11
enum('G','PG','PG-13','R','NC-17') geostd8 1
set('one', 'two') geostd8 1
not_exist geostd8 0
char(-1) geostd8 0
char(10) keybcs2 10
char(256) keybcs2 255
binary(10) keybcs2 10
binary(256) keybcs2 255
varchar(10) keybcs2 11
varbinary(10) keybcs2 11
enum('G','PG','PG-13','R','NC-17') keybcs2 1
set('one', 'two') keybcs2 1
not_exist keybcs2 0
char(-1) keybcs2 0
char(10) ucs2 20
char(256) ucs2 510
binary(10) ucs2 10
binary(256) ucs2 255
varchar(10) ucs2 21
varbinary(10) ucs2 21
enum('G','PG','PG-13','R','NC-17') ucs2 1
set('one', 'two') ucs2 1
not_exist ucs2 0
char(-1) ucs2 0
char(10) utf32 40
char(256) utf32 1020
binary(10) utf32 10
binary(256) utf32 255
varchar(10) utf32 41
varbinary(10) utf32 41
enum('G','PG','PG-13','R','NC-17') utf32 1
set('one', 'two') utf32 1
not_exist utf32 0
char(-1) utf32 0
char(10) armscii8 10
char(256) armscii8 255
binary(10) armscii8 10
binary(256) armscii8 255
varchar(10) armscii8 11
varbinary(10) armscii8 11
enum('G','PG','PG-13','R','NC-17') armscii8 1
set('one', 'two') armscii8 1
not_exist armscii8 0
char(-1) armscii8 0
char(10) ascii 10
char(256) ascii 255
binary(10) ascii 10
binary(256) ascii 255
varchar(10) ascii 11
varbinary(10) ascii 11
enum('G','PG','PG-13','R','NC-17') ascii 1
set('one', 'two') ascii 1
not_exist ascii 0
char(-1) ascii 0
char(10) dec8 10
char(256) dec8 255
binary(10) dec8 10
......@@ -88,24 +117,17 @@ varbinary(10) dec8 11
enum('G','PG','PG-13','R','NC-17') dec8 1
set('one', 'two') dec8 1
not_exist dec8 0
char(10) hebrew 10
char(256) hebrew 255
binary(10) hebrew 10
binary(256) hebrew 255
varchar(10) hebrew 11
varbinary(10) hebrew 11
enum('G','PG','PG-13','R','NC-17') hebrew 1
set('one', 'two') hebrew 1
not_exist hebrew 0
char(10) koi8u 10
char(256) koi8u 255
binary(10) koi8u 10
binary(256) koi8u 255
varchar(10) koi8u 11
varbinary(10) koi8u 11
enum('G','PG','PG-13','R','NC-17') koi8u 1
set('one', 'two') koi8u 1
not_exist koi8u 0
char(-1) dec8 0
char(10) eucjpms 30
char(256) eucjpms 765
binary(10) eucjpms 10
binary(256) eucjpms 255
varchar(10) eucjpms 31
varbinary(10) eucjpms 31
enum('G','PG','PG-13','R','NC-17') eucjpms 1
set('one', 'two') eucjpms 1
not_exist eucjpms 0
char(-1) eucjpms 0
char(10) latin2 10
char(256) latin2 255
binary(10) latin2 10
......@@ -115,42 +137,57 @@ varbinary(10) latin2 11
enum('G','PG','PG-13','R','NC-17') latin2 1
set('one', 'two') latin2 1
not_exist latin2 0
char(10) macce 10
char(256) macce 255
binary(10) macce 10
binary(256) macce 255
varchar(10) macce 11
varbinary(10) macce 11
enum('G','PG','PG-13','R','NC-17') macce 1
set('one', 'two') macce 1
not_exist macce 0
char(10) sjis 20
char(256) sjis 510
binary(10) sjis 10
binary(256) sjis 255
varchar(10) sjis 21
varbinary(10) sjis 21
enum('G','PG','PG-13','R','NC-17') sjis 1
set('one', 'two') sjis 1
not_exist sjis 0
char(10) tis620 10
char(256) tis620 255
binary(10) tis620 10
binary(256) tis620 255
varchar(10) tis620 11
varbinary(10) tis620 11
enum('G','PG','PG-13','R','NC-17') tis620 1
set('one', 'two') tis620 1
not_exist tis620 0
char(10) ucs2 20
char(256) ucs2 510
binary(10) ucs2 10
binary(256) ucs2 255
varchar(10) ucs2 21
varbinary(10) ucs2 21
enum('G','PG','PG-13','R','NC-17') ucs2 1
set('one', 'two') ucs2 1
not_exist ucs2 0
char(-1) latin2 0
char(10) cp1257 10
char(256) cp1257 255
binary(10) cp1257 10
binary(256) cp1257 255
varchar(10) cp1257 11
varbinary(10) cp1257 11
enum('G','PG','PG-13','R','NC-17') cp1257 1
set('one', 'two') cp1257 1
not_exist cp1257 0
char(-1) cp1257 0
char(10) cp932 20
char(256) cp932 510
binary(10) cp932 10
binary(256) cp932 255
varchar(10) cp932 21
varbinary(10) cp932 21
enum('G','PG','PG-13','R','NC-17') cp932 1
set('one', 'two') cp932 1
not_exist cp932 0
char(-1) cp932 0
char(10) cp1250 10
char(256) cp1250 255
binary(10) cp1250 10
binary(256) cp1250 255
varchar(10) cp1250 11
varbinary(10) cp1250 11
enum('G','PG','PG-13','R','NC-17') cp1250 1
set('one', 'two') cp1250 1
not_exist cp1250 0
char(-1) cp1250 0
char(10) greek 10
char(256) greek 255
binary(10) greek 10
binary(256) greek 255
varchar(10) greek 11
varbinary(10) greek 11
enum('G','PG','PG-13','R','NC-17') greek 1
set('one', 'two') greek 1
not_exist greek 0
char(-1) greek 0
char(10) swe7 10
char(256) swe7 255
binary(10) swe7 10
binary(256) swe7 255
varchar(10) swe7 11
varbinary(10) swe7 11
enum('G','PG','PG-13','R','NC-17') swe7 1
set('one', 'two') swe7 1
not_exist swe7 0
char(-1) swe7 0
char(10) utf8 30
char(256) utf8 765
binary(10) utf8 10
......@@ -160,15 +197,27 @@ varbinary(10) utf8 31
enum('G','PG','PG-13','R','NC-17') utf8 1
set('one', 'two') utf8 1
not_exist utf8 0
char(10) armscii8 10
char(256) armscii8 255
binary(10) armscii8 10
binary(256) armscii8 255
varchar(10) armscii8 11
varbinary(10) armscii8 11
enum('G','PG','PG-13','R','NC-17') armscii8 1
set('one', 'two') armscii8 1
not_exist armscii8 0
char(-1) utf8 0
char(10) utf8mb4 40
char(256) utf8mb4 1020
binary(10) utf8mb4 10
binary(256) utf8mb4 255
varchar(10) utf8mb4 41
varbinary(10) utf8mb4 41
enum('G','PG','PG-13','R','NC-17') utf8mb4 1
set('one', 'two') utf8mb4 1
not_exist utf8mb4 0
char(-1) utf8mb4 0
char(10) cp850 10
char(256) cp850 255
binary(10) cp850 10
binary(256) cp850 255
varchar(10) cp850 11
varbinary(10) cp850 11
enum('G','PG','PG-13','R','NC-17') cp850 1
set('one', 'two') cp850 1
not_exist cp850 0
char(-1) cp850 0
char(10) euckr 20
char(256) euckr 510
binary(10) euckr 10
......@@ -178,24 +227,37 @@ varbinary(10) euckr 21
enum('G','PG','PG-13','R','NC-17') euckr 1
set('one', 'two') euckr 1
not_exist euckr 0
char(10) keybcs2 10
char(256) keybcs2 255
binary(10) keybcs2 10
binary(256) keybcs2 255
varchar(10) keybcs2 11
varbinary(10) keybcs2 11
enum('G','PG','PG-13','R','NC-17') keybcs2 1
set('one', 'two') keybcs2 1
not_exist keybcs2 0
char(10) ascii 10
char(256) ascii 255
binary(10) ascii 10
binary(256) ascii 255
varchar(10) ascii 11
varbinary(10) ascii 11
enum('G','PG','PG-13','R','NC-17') ascii 1
set('one', 'two') ascii 1
not_exist ascii 0
char(-1) euckr 0
char(10) hp8 10
char(256) hp8 255
binary(10) hp8 10
binary(256) hp8 255
varchar(10) hp8 11
varbinary(10) hp8 11
enum('G','PG','PG-13','R','NC-17') hp8 1
set('one', 'two') hp8 1
not_exist hp8 0
char(-1) hp8 0
char(10) koi8u 10
char(256) koi8u 255
binary(10) koi8u 10
binary(256) koi8u 255
varchar(10) koi8u 11
varbinary(10) koi8u 11
enum('G','PG','PG-13','R','NC-17') koi8u 1
set('one', 'two') koi8u 1
not_exist koi8u 0
char(-1) koi8u 0
char(10) macce 10
char(256) macce 255
binary(10) macce 10
binary(256) macce 255
varchar(10) macce 11
varbinary(10) macce 11
enum('G','PG','PG-13','R','NC-17') macce 1
set('one', 'two') macce 1
not_exist macce 0
char(-1) macce 0
char(10) binary 10
char(256) binary 255
binary(10) binary 10
......@@ -205,60 +267,7 @@ varbinary(10) binary 11
enum('G','PG','PG-13','R','NC-17') binary 1
set('one', 'two') binary 1
not_exist binary 0
char(10) cp1251 10
char(256) cp1251 255
binary(10) cp1251 10
binary(256) cp1251 255
varchar(10) cp1251 11
varbinary(10) cp1251 11
enum('G','PG','PG-13','R','NC-17') cp1251 1
set('one', 'two') cp1251 1
not_exist cp1251 0
char(10) utf8mb4 40
char(256) utf8mb4 1020
binary(10) utf8mb4 10
binary(256) utf8mb4 255
varchar(10) utf8mb4 41
varbinary(10) utf8mb4 41
enum('G','PG','PG-13','R','NC-17') utf8mb4 1
set('one', 'two') utf8mb4 1
not_exist utf8mb4 0
char(10) cp852 10
char(256) cp852 255
binary(10) cp852 10
binary(256) cp852 255
varchar(10) cp852 11
varbinary(10) cp852 11
enum('G','PG','PG-13','R','NC-17') cp852 1
set('one', 'two') cp852 1
not_exist cp852 0
char(10) koi8r 10
char(256) koi8r 255
binary(10) koi8r 10
binary(256) koi8r 255
varchar(10) koi8r 11
varbinary(10) koi8r 11
enum('G','PG','PG-13','R','NC-17') koi8r 1
set('one', 'two') koi8r 1
not_exist koi8r 0
char(10) cp866 10
char(256) cp866 255
binary(10) cp866 10
binary(256) cp866 255
varchar(10) cp866 11
varbinary(10) cp866 11
enum('G','PG','PG-13','R','NC-17') cp866 1
set('one', 'two') cp866 1
not_exist cp866 0
char(10) eucjpms 30
char(256) eucjpms 765
binary(10) eucjpms 10
binary(256) eucjpms 255
varchar(10) eucjpms 31
varbinary(10) eucjpms 31
enum('G','PG','PG-13','R','NC-17') eucjpms 1
set('one', 'two') eucjpms 1
not_exist eucjpms 0
char(-1) binary 0
char(10) gb18030 40
char(256) gb18030 1020
binary(10) gb18030 10
......@@ -268,51 +277,57 @@ varbinary(10) gb18030 41
enum('G','PG','PG-13','R','NC-17') gb18030 1
set('one', 'two') gb18030 1
not_exist gb18030 0
char(10) hp8 10
char(256) hp8 255
binary(10) hp8 10
binary(256) hp8 255
varchar(10) hp8 11
varbinary(10) hp8 11
enum('G','PG','PG-13','R','NC-17') hp8 1
set('one', 'two') hp8 1
not_exist hp8 0
char(10) swe7 10
char(256) swe7 255
binary(10) swe7 10
binary(256) swe7 255
varchar(10) swe7 11
varbinary(10) swe7 11
enum('G','PG','PG-13','R','NC-17') swe7 1
set('one', 'two') swe7 1
not_exist swe7 0
char(10) greek 10
char(256) greek 255
binary(10) greek 10
binary(256) greek 255
varchar(10) greek 11
varbinary(10) greek 11
enum('G','PG','PG-13','R','NC-17') greek 1
set('one', 'two') greek 1
not_exist greek 0
char(10) macroman 10
char(256) macroman 255
binary(10) macroman 10
binary(256) macroman 255
varchar(10) macroman 11
varbinary(10) macroman 11
enum('G','PG','PG-13','R','NC-17') macroman 1
set('one', 'two') macroman 1
not_exist macroman 0
char(10) ujis 30
char(256) ujis 765
binary(10) ujis 10
binary(256) ujis 255
varchar(10) ujis 31
varbinary(10) ujis 31
enum('G','PG','PG-13','R','NC-17') ujis 1
set('one', 'two') ujis 1
not_exist ujis 0
char(-1) gb18030 0
char(10) gb2312 20
char(256) gb2312 510
binary(10) gb2312 10
binary(256) gb2312 255
varchar(10) gb2312 21
varbinary(10) gb2312 21
enum('G','PG','PG-13','R','NC-17') gb2312 1
set('one', 'two') gb2312 1
not_exist gb2312 0
char(-1) gb2312 0
char(10) latin5 10
char(256) latin5 255
binary(10) latin5 10
binary(256) latin5 255
varchar(10) latin5 11
varbinary(10) latin5 11
enum('G','PG','PG-13','R','NC-17') latin5 1
set('one', 'two') latin5 1
not_exist latin5 0
char(-1) latin5 0
char(10) big5 20
char(256) big5 510
binary(10) big5 10
binary(256) big5 255
varchar(10) big5 21
varbinary(10) big5 21
enum('G','PG','PG-13','R','NC-17') big5 1
set('one', 'two') big5 1
not_exist big5 0
char(-1) big5 0
char(10) koi8r 10
char(256) koi8r 255
binary(10) koi8r 10
binary(256) koi8r 255
varchar(10) koi8r 11
varbinary(10) koi8r 11
enum('G','PG','PG-13','R','NC-17') koi8r 1
set('one', 'two') koi8r 1
not_exist koi8r 0
char(-1) koi8r 0
char(10) sjis 20
char(256) sjis 510
binary(10) sjis 10
binary(256) sjis 255
varchar(10) sjis 21
varbinary(10) sjis 21
enum('G','PG','PG-13','R','NC-17') sjis 1
set('one', 'two') sjis 1
not_exist sjis 0
char(-1) sjis 0
char(10) utf16le 40
char(256) utf16le 1020
binary(10) utf16le 10
......@@ -322,42 +337,17 @@ varbinary(10) utf16le 41
enum('G','PG','PG-13','R','NC-17') utf16le 1
set('one', 'two') utf16le 1
not_exist utf16le 0
char(10) cp1256 10
char(256) cp1256 255
binary(10) cp1256 10
binary(256) cp1256 255
varchar(10) cp1256 11
varbinary(10) cp1256 11
enum('G','PG','PG-13','R','NC-17') cp1256 1
set('one', 'two') cp1256 1
not_exist cp1256 0
char(10) cp850 10
char(256) cp850 255
binary(10) cp850 10
binary(256) cp850 255
varchar(10) cp850 11
varbinary(10) cp850 11
enum('G','PG','PG-13','R','NC-17') cp850 1
set('one', 'two') cp850 1
not_exist cp850 0
char(10) gbk 20
char(256) gbk 510
binary(10) gbk 10
binary(256) gbk 255
varchar(10) gbk 21
varbinary(10) gbk 21
enum('G','PG','PG-13','R','NC-17') gbk 1
set('one', 'two') gbk 1
not_exist gbk 0
char(10) geostd8 10
char(256) geostd8 255
binary(10) geostd8 10
binary(256) geostd8 255
varchar(10) geostd8 11
varbinary(10) geostd8 11
enum('G','PG','PG-13','R','NC-17') geostd8 1
set('one', 'two') geostd8 1
not_exist geostd8 0
char(-1) utf16le 0
char(10) tis620 10
char(256) tis620 255
binary(10) tis620 10
binary(256) tis620 255
varchar(10) tis620 11
varbinary(10) tis620 11
enum('G','PG','PG-13','R','NC-17') tis620 1
set('one', 'two') tis620 1
not_exist tis620 0
char(-1) tis620 0
char(10) utf16 40
char(256) utf16 1020
binary(10) utf16 10
......@@ -367,3 +357,54 @@ varbinary(10) utf16 41
enum('G','PG','PG-13','R','NC-17') utf16 1
set('one', 'two') utf16 1
not_exist utf16 0
char(-1) utf16 0
char(10) cp1251 10
char(256) cp1251 255
binary(10) cp1251 10
binary(256) cp1251 255
varchar(10) cp1251 11
varbinary(10) cp1251 11
enum('G','PG','PG-13','R','NC-17') cp1251 1
set('one', 'two') cp1251 1
not_exist cp1251 0
char(-1) cp1251 0
char(10) gbk 20
char(256) gbk 510
binary(10) gbk 10
binary(256) gbk 255
varchar(10) gbk 21
varbinary(10) gbk 21
enum('G','PG','PG-13','R','NC-17') gbk 1
set('one', 'two') gbk 1
not_exist gbk 0
char(-1) gbk 0
char(10) hebrew 10
char(256) hebrew 255
binary(10) hebrew 10
binary(256) hebrew 255
varchar(10) hebrew 11
varbinary(10) hebrew 11
enum('G','PG','PG-13','R','NC-17') hebrew 1
set('one', 'two') hebrew 1
not_exist hebrew 0
char(-1) hebrew 0
char(10) latin1 10
char(256) latin1 255
binary(10) latin1 10
binary(256) latin1 255
varchar(10) latin1 11
varbinary(10) latin1 11
enum('G','PG','PG-13','R','NC-17') latin1 1
set('one', 'two') latin1 1
not_exist latin1 0
char(-1) latin1 0
char(10) macroman 10
char(256) macroman 255
binary(10) macroman 10
binary(256) macroman 255
varchar(10) macroman 11
varbinary(10) macroman 11
enum('G','PG','PG-13','R','NC-17') macroman 1
set('one', 'two') macroman 1
not_exist macroman 0
char(-1) macroman 0
[]database.ReferenceValue{
{ReferencedTableSchema:"sakila", ReferencedTableName:"language", TableSchema:"sakila", TableName:"film", ConstraintName:"fk_film_language"},
{ReferencedTableSchema:"sakila", ReferencedTableName:"language", TableSchema:"sakila", TableName:"film", ConstraintName:"fk_film_language_original"},
}
[]database.ReferenceValue(nil)
......@@ -2,3 +2,4 @@ select 1 []database.TraceRow{
{Query:"explain select 1", Trace:"{\n \"steps\": [\n {\n \"join_preparation\": {\n \"select#\": 1,\n \"steps\": [\n {\n \"expanded_query\": \"/* select#1 */ select 1 AS `1`\"\n }\n ]\n }\n },\n {\n \"join_optimization\": {\n \"select#\": 1,\n \"steps\": [\n ]\n }\n },\n {\n \"join_explain\": {\n \"select#\": 1,\n \"steps\": [\n ]\n }\n }\n ]\n}", MissingBytesBeyondMaxMemSize:0, InsufficientPrivileges:0},
} nil
explain select 1 []database.TraceRow(nil) &errors.errorString{s:"no need trace"}
show create table film []database.TraceRow(nil) &errors.errorString{s:"no need trace"}
......@@ -46,7 +46,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -102,7 +102,7 @@ WHERE
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
* **Item:** ARG.006
......@@ -110,7 +110,7 @@ WHERE
* **Content:** 使用 IS NULL 或 IS NOT NULL 将可能导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null;可以在num上设置默认值0,确保表中 num 列没有 NULL 值,然后这样查询: select id from t where num=0;
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -151,7 +151,7 @@ HAVING
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -159,7 +159,7 @@ HAVING
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 HAVING 子句
## 不建议使用 HAVING 子句
* **Item:** CLA.013
......@@ -167,7 +167,7 @@ HAVING
* **Content:** 将查询的 HAVING 子句改写为 WHERE 中的查询条件,可以在查询处理期间使用索引。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -223,7 +223,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -280,7 +280,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -325,7 +325,7 @@ WHERE
* **Using index condition**: 在5.6版本后加入的新特性(Index Condition Pushdown)。Using index condition 会先条件过滤索引,过滤完索引后找到所有符合索引条件的数据行,随后用 WHERE 子句中的其他条件去过滤这些数据行。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -370,7 +370,7 @@ WHERE
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
* **Item:** ARG.006
......@@ -378,7 +378,7 @@ WHERE
* **Content:** 使用 IS NULL 或 IS NOT NULL 将可能导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null;可以在num上设置默认值0,确保表中 num 列没有 NULL 值,然后这样查询: select id from t where num=0;
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -435,7 +435,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -492,7 +492,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -550,7 +550,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -607,7 +607,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -668,7 +668,7 @@ GROUP BY
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -676,7 +676,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## 使用 SUM(COL) 时需注意 NPE 问题
## 使用 SUM(COL) 时需注意 NPE 问题
* **Item:** FUN.006
......@@ -736,7 +736,7 @@ GROUP BY
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -744,7 +744,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## 使用 SUM(COL) 时需注意 NPE 问题
## 使用 SUM(COL) 时需注意 NPE 问题
* **Item:** FUN.006
......@@ -800,7 +800,7 @@ GROUP BY
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -808,7 +808,7 @@ GROUP BY
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -816,7 +816,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## 使用 SUM(COL) 时需注意 NPE 问题
## 使用 SUM(COL) 时需注意 NPE 问题
* **Item:** FUN.006
......@@ -876,7 +876,7 @@ GROUP BY
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -884,7 +884,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## GROUP BY 的条件为表达式
## GROUP BY 的条件为表达式
* **Item:** CLA.010
......@@ -892,7 +892,7 @@ GROUP BY
* **Content:** 当 GROUP BY 条件为表达式或函数时会使用到临时表,如果在未指定 WHERE 或 WHERE 条件返回的结果集较大时性能会很差。
## 使用 SUM(COL) 时需注意 NPE 问题
## 使用 SUM(COL) 时需注意 NPE 问题
* **Item:** FUN.006
......@@ -948,7 +948,7 @@ GROUP BY
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -956,7 +956,7 @@ GROUP BY
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -989,7 +989,7 @@ GROUP BY
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -997,7 +997,7 @@ GROUP BY
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -1005,7 +1005,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1013,7 +1013,7 @@ GROUP BY
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 非确定性的 GROUP BY
## 非确定性的 GROUP BY
* **Item:** RES.001
......@@ -1060,7 +1060,7 @@ GROUP BY
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -1068,7 +1068,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## 避免在 WHERE 条件中使用函数或其他运算符
## 避免在 WHERE 条件中使用函数或其他运算符
* **Item:** FUN.001
......@@ -1105,7 +1105,7 @@ ORDER BY
## 非确定性的 GROUP BY
## 非确定性的 GROUP BY
* **Item:** RES.001
......@@ -1221,7 +1221,7 @@ ORDER BY
## ORDER BY 语句对多个不同条件使用不同方向的排序无法使用索引
## ORDER BY 语句对多个不同条件使用不同方向的排序无法使用索引
* **Item:** CLA.007
......@@ -1229,7 +1229,7 @@ ORDER BY
* **Content:** ORDER BY 子句中的所有表达式必须按统一的 ASC 或 DESC 方向排序,以便利用索引。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1237,7 +1237,7 @@ ORDER BY
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## ORDER BY 多个列但排序方向不同时可能无法使用索引
## ORDER BY 多个列但排序方向不同时可能无法使用索引
* **Item:** KEY.008
......@@ -1357,7 +1357,7 @@ LIMIT
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1404,7 +1404,7 @@ LIMIT
* ☠️ **Using filesort**: MySQL会对结果使用一个外部索引排序,而不是从表里按照索引次序读到相关内容. 可能在内存或者磁盘上进行排序. MySQL中无法利用索引完成的排序操作称为'文件排序'.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -1412,7 +1412,7 @@ LIMIT
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1459,7 +1459,7 @@ LIMIT
* ☠️ **Using filesort**: MySQL会对结果使用一个外部索引排序,而不是从表里按照索引次序读到相关内容. 可能在内存或者磁盘上进行排序. MySQL中无法利用索引完成的排序操作称为'文件排序'.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -1521,7 +1521,7 @@ LIMIT
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1583,7 +1583,7 @@ LIMIT
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1643,7 +1643,7 @@ ORDER BY
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1704,7 +1704,7 @@ ORDER BY
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1712,7 +1712,7 @@ ORDER BY
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## '!=' 运算符是非标准的
## '!=' 运算符是非标准的
* **Item:** STA.001
......@@ -1923,7 +1923,7 @@ ORDER BY
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -1986,7 +1986,7 @@ ORDER BY
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2046,7 +2046,7 @@ ORDER BY
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2089,7 +2089,7 @@ FROM
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2097,7 +2097,7 @@ FROM
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2105,7 +2105,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2148,7 +2148,7 @@ FROM
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2156,7 +2156,7 @@ FROM
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2164,7 +2164,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2207,7 +2207,7 @@ FROM
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2215,7 +2215,7 @@ FROM
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2223,7 +2223,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2285,7 +2285,7 @@ WHERE
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2293,7 +2293,7 @@ WHERE
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
* **Item:** ARG.006
......@@ -2301,7 +2301,7 @@ WHERE
* **Content:** 使用 IS NULL 或 IS NOT NULL 将可能导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null;可以在num上设置默认值0,确保表中 num 列没有 NULL 值,然后这样查询: select id from t where num=0;
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2363,7 +2363,7 @@ WHERE
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2371,7 +2371,7 @@ WHERE
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
## 应尽量避免在 WHERE 子句中对字段进行 NULL 值判断
* **Item:** ARG.006
......@@ -2379,7 +2379,7 @@ WHERE
* **Content:** 使用 IS NULL 或 IS NOT NULL 将可能导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null;可以在num上设置默认值0,确保表中 num 列没有 NULL 值,然后这样查询: select id from t where num=0;
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2435,7 +2435,7 @@ FROM
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2443,7 +2443,7 @@ FROM
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2451,7 +2451,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2459,7 +2459,7 @@ FROM
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
* **Item:** SUB.002
......@@ -2547,7 +2547,7 @@ WHERE
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2555,7 +2555,7 @@ WHERE
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -2563,7 +2563,7 @@ WHERE
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
* **Item:** SUB.002
......@@ -2610,7 +2610,7 @@ FROM
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2657,7 +2657,7 @@ FROM
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2704,7 +2704,7 @@ FROM
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2750,7 +2750,7 @@ FROM
* **Using index**: 只需通过索引就可以从表中获取列的信息, 无需额外去读取真实的行数据. 如果查询使用的列值仅仅是一个简单索引的部分值, 则会使用这种策略来优化查询.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2758,7 +2758,7 @@ FROM
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2810,7 +2810,7 @@ FROM
* **Using index**: 只需通过索引就可以从表中获取列的信息, 无需额外去读取真实的行数据. 如果查询使用的列值仅仅是一个简单索引的部分值, 则会使用这种策略来优化查询.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -2818,7 +2818,7 @@ FROM
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2826,7 +2826,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## MySQL 对子查询的优化效果不佳
## MySQL 对子查询的优化效果不佳
* **Item:** SUB.001
......@@ -2906,7 +2906,7 @@ ORDER BY
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -2914,7 +2914,7 @@ ORDER BY
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 同一张表被连接两次
## 同一张表被连接两次
* **Item:** JOI.002
......@@ -2922,7 +2922,7 @@ ORDER BY
* **Content:** 相同的表在 FROM 子句中至少出现两次,可以简化为对该表的单次访问。
## MySQL 对子查询的优化效果不佳
## MySQL 对子查询的优化效果不佳
* **Item:** SUB.001
......@@ -2959,7 +2959,7 @@ WHERE
* **const**: const用于使用常数值比较PRIMARY KEY时, 当查询的表仅有一行时, 使用system. 例:SELECT * FROM tbl WHERE col = 1.
## 不建议使用联表删除或更新
## 不建议使用联表删除或更新
* **Item:** JOI.007
......@@ -2967,7 +2967,7 @@ WHERE
* **Content:** 当需要同时删除或更新多张表时建议使用简单语句,一条 SQL 只删除或更新一张表,尽量不要将多张表的操作在同一条语句。
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
* **Item:** SEC.003
......@@ -3027,7 +3027,7 @@ WHERE
## 不建议使用联表删除或更新
## 不建议使用联表删除或更新
* **Item:** JOI.007
......@@ -3035,7 +3035,7 @@ WHERE
* **Content:** 当需要同时删除或更新多张表时建议使用简单语句,一条 SQL 只删除或更新一张表,尽量不要将多张表的操作在同一条语句。
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
* **Item:** SEC.003
......@@ -3074,7 +3074,7 @@ WHERE
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 不建议使用联表删除或更新
## 不建议使用联表删除或更新
* **Item:** JOI.007
......@@ -3082,7 +3082,7 @@ WHERE
* **Content:** 当需要同时删除或更新多张表时建议使用简单语句,一条 SQL 只删除或更新一张表,尽量不要将多张表的操作在同一条语句。
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
* **Item:** SEC.003
......@@ -3121,7 +3121,7 @@ WHERE
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 不建议使用联表删除或更新
## 不建议使用联表删除或更新
* **Item:** JOI.007
......@@ -3129,7 +3129,7 @@ WHERE
* **Content:** 当需要同时删除或更新多张表时建议使用简单语句,一条 SQL 只删除或更新一张表,尽量不要将多张表的操作在同一条语句。
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
* **Item:** SEC.003
......@@ -3179,7 +3179,7 @@ WHERE
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
## 使用DELETE/DROP/TRUNCATE等操作时注意备份
* **Item:** SEC.003
......@@ -3220,7 +3220,7 @@ WHERE
* **const**: const用于使用常数值比较PRIMARY KEY时, 当查询的表仅有一行时, 使用system. 例:SELECT * FROM tbl WHERE col = 1.
## 不建议使用联表删除或更新
## 不建议使用联表删除或更新
* **Item:** JOI.007
......@@ -3273,7 +3273,7 @@ WHERE
* **Using index**: 只需通过索引就可以从表中获取列的信息, 无需额外去读取真实的行数据. 如果查询使用的列值仅仅是一个简单索引的部分值, 则会使用这种策略来优化查询.
## 不建议使用联表删除或更新
## 不建议使用联表删除或更新
* **Item:** JOI.007
......@@ -3385,7 +3385,7 @@ FROM
* **Using index**: 只需通过索引就可以从表中获取列的信息, 无需额外去读取真实的行数据. 如果查询使用的列值仅仅是一个简单索引的部分值, 则会使用这种策略来优化查询.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -3393,7 +3393,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
* **Item:** LCK.001
......@@ -3455,7 +3455,7 @@ FROM
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
* **Item:** LCK.001
......@@ -3501,7 +3501,7 @@ FROM
* **Using index**: 只需通过索引就可以从表中获取列的信息, 无需额外去读取真实的行数据. 如果查询使用的列值仅仅是一个简单索引的部分值, 则会使用这种策略来优化查询.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -3509,7 +3509,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
* **Item:** LCK.001
......@@ -3571,7 +3571,7 @@ FROM
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
## INSERT INTO xx SELECT 加锁粒度较大请谨慎
* **Item:** LCK.001
......@@ -3694,7 +3694,7 @@ FROM
* **Using index**: 只需通过索引就可以从表中获取列的信息, 无需额外去读取真实的行数据. 如果查询使用的列值仅仅是一个简单索引的部分值, 则会使用这种策略来优化查询.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -3702,7 +3702,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 执行计划中嵌套连接深度过深
## 执行计划中嵌套连接深度过深
* **Item:** SUB.004
......@@ -3760,7 +3760,7 @@ LIMIT
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -3768,7 +3768,7 @@ LIMIT
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -3776,7 +3776,7 @@ LIMIT
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 未使用 ORDER BY 的 LIMIT 查询
## 未使用 ORDER BY 的 LIMIT 查询
* **Item:** RES.002
......@@ -3784,7 +3784,7 @@ LIMIT
* **Content:** 没有 ORDER BY 的 LIMIT 会导致非确定性的结果,这取决于查询执行计划。
## MySQL 对子查询的优化效果不佳
## MySQL 对子查询的优化效果不佳
* **Item:** SUB.001
......@@ -3838,7 +3838,7 @@ FROM
* ☠️ **ALL**: 最坏的情况, 从头到尾全表扫描.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -3846,7 +3846,7 @@ FROM
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -3854,7 +3854,7 @@ FROM
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -3862,7 +3862,7 @@ FROM
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
* **Item:** SUB.002
......@@ -3906,7 +3906,7 @@ GROUP BY
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -3914,7 +3914,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -3922,7 +3922,7 @@ GROUP BY
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 非确定性的 GROUP BY
## 非确定性的 GROUP BY
* **Item:** RES.001
......@@ -3930,7 +3930,7 @@ GROUP BY
* **Content:** SQL返回的列既不在聚合函数中也不是 GROUP BY 表达式的列中,因此这些值的结果将是非确定性的。如:select a, b, c from tbl where foo="bar" group by a,该 SQL 返回的结果就是不确定的。
## MySQL 对子查询的优化效果不佳
## MySQL 对子查询的优化效果不佳
* **Item:** SUB.001
......@@ -3994,7 +3994,7 @@ WHERE
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -4002,7 +4002,7 @@ WHERE
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -4010,7 +4010,7 @@ WHERE
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
## 如果您不在乎重复的话,建议使用 UNION ALL 替代 UNION
* **Item:** SUB.002
......@@ -4056,7 +4056,7 @@ FROM
* **Using index**: 只需通过索引就可以从表中获取列的信息, 无需额外去读取真实的行数据. 如果查询使用的列值仅仅是一个简单索引的部分值, 则会使用这种策略来优化查询.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -4149,7 +4149,7 @@ ORDER BY
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -4157,7 +4157,7 @@ ORDER BY
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -4165,7 +4165,7 @@ ORDER BY
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## ORDER BY 语句对多个不同条件使用不同方向的排序无法使用索引
## ORDER BY 语句对多个不同条件使用不同方向的排序无法使用索引
* **Item:** CLA.007
......@@ -4173,7 +4173,7 @@ ORDER BY
* **Content:** ORDER BY 子句中的所有表达式必须按统一的 ASC 或 DESC 方向排序,以便利用索引。
## 同一张表被连接两次
## 同一张表被连接两次
* **Item:** JOI.002
......@@ -4181,7 +4181,7 @@ ORDER BY
* **Content:** 相同的表在 FROM 子句中至少出现两次,可以简化为对该表的单次访问。
## MySQL 对子查询的优化效果不佳
## MySQL 对子查询的优化效果不佳
* **Item:** SUB.001
......@@ -4226,7 +4226,7 @@ WHERE
* **Using where**: WHERE条件用于筛选出与下一个表匹配的数据然后返回给客户端. 除非故意做的全表扫描, 否则连接类型是ALL或者是index, 且在Extra列的值中没有Using Where, 则该查询可能是有问题的.
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......@@ -4234,7 +4234,7 @@ WHERE
* **Content:** 当表结构变更时,使用 \* 通配符选择所有列将导致查询的含义和行为会发生更改,可能导致查询返回更多的数据。
## 避免在 WHERE 条件中使用函数或其他运算符
## 避免在 WHERE 条件中使用函数或其他运算符
* **Item:** FUN.001
......@@ -4256,7 +4256,7 @@ GROUP BY
DATE( last_update)
```
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -4264,7 +4264,7 @@ GROUP BY
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -4272,7 +4272,7 @@ GROUP BY
* **Content:** 默认 MySQL 会对 'GROUP BY col1, col2, ...' 请求按如下顺序排序 'ORDER BY col1, col2, ...'。如果 GROUP BY 语句不指定 ORDER BY 条件会导致无谓的排序产生,如果不需要排序建议添加 'ORDER BY NULL'。
## GROUP BY 的条件为表达式
## GROUP BY 的条件为表达式
* **Item:** CLA.010
......@@ -4317,7 +4317,7 @@ ORDER BY
* ☠️ **Using filesort**: MySQL会对结果使用一个外部索引排序,而不是从表里按照索引次序读到相关内容. 可能在内存或者磁盘上进行排序. MySQL中无法利用索引完成的排序操作称为'文件排序'.
## 最外层 SELECT 未指定 WHERE 条件
## 最外层 SELECT 未指定 WHERE 条件
* **Item:** CLA.001
......@@ -4325,7 +4325,7 @@ ORDER BY
* **Content:** SELECT 语句没有 WHERE 子句,可能检查比预期更多的行(全表扫描)。对于 SELECT COUNT(\*) 类型的请求如果不要求精度,建议使用 SHOW TABLE STATUS 或 EXPLAIN 替代。
## ORDER BY 的条件为表达式
## ORDER BY 的条件为表达式
* **Item:** CLA.009
......@@ -4387,7 +4387,7 @@ GROUP BY
## 请为 GROUP BY 显示添加 ORDER BY 条件
## 请为 GROUP BY 显示添加 ORDER BY 条件
* **Item:** CLA.008
......@@ -4407,7 +4407,7 @@ ADD
index idx_city_id( city_id)
```
## OK
## OK
# Query: C315BC4EE0F4E523
......@@ -4422,7 +4422,7 @@ ADD
`store_id`, `film_id`)
```
## 提醒:请将索引属性顺序与查询对齐
## 提醒:请将索引属性顺序与查询对齐
* **Item:** KEY.004
......@@ -4460,7 +4460,7 @@ ADD
* **Case:** alter table inventory add index \`idx\_store\_film\` (\`store\_id\`,\`film\_id\`),add index \`idx\_store\_film\` (\`store\_id\`,\`film\_id\`),add index \`idx\_store\_film\` (\`store\_id\`,\`film\_id\`)
## 提醒:请将索引属性顺序与查询对齐
## 提醒:请将索引属性顺序与查询对齐
* **Item:** KEY.004
......@@ -4519,7 +4519,7 @@ ORDER BY
## 建议使用 AS 关键字显示声明一个别名
## 建议使用 AS 关键字显示声明一个别名
* **Item:** ALI.001
......@@ -4527,7 +4527,7 @@ ORDER BY
* **Content:** 在列或表别名(如"tbl AS alias")中, 明确使用 AS 关键字比隐含别名(如"tbl alias")更易懂。
## 不建议使用前项通配符查找
## 不建议使用前项通配符查找
* **Item:** ARG.001
......@@ -4535,7 +4535,7 @@ ORDER BY
* **Content:** 例如 "%foo",查询参数有一个前项通配符的情况无法使用已有索引。
## ORDER BY 的条件为表达式
## ORDER BY 的条件为表达式
* **Item:** CLA.009
......@@ -4543,7 +4543,7 @@ ORDER BY
* **Content:** 当 ORDER BY 条件为表达式或函数时会使用到临时表,如果在未指定 WHERE 或 WHERE 条件返回的结果集较大时性能会很差。
## GROUP BY 的条件为表达式
## GROUP BY 的条件为表达式
* **Item:** CLA.010
......@@ -4551,7 +4551,7 @@ ORDER BY
* **Content:** 当 GROUP BY 条件为表达式或函数时会使用到临时表,如果在未指定 WHERE 或 WHERE 条件返回的结果集较大时性能会很差。
## ORDER BY 多个列但排序方向不同时可能无法使用索引
## ORDER BY 多个列但排序方向不同时可能无法使用索引
* **Item:** KEY.008
......@@ -4567,7 +4567,7 @@ ORDER BY
create table hello. t (id int unsigned)
```
## 建议为表添加注释
## 建议为表添加注释
* **Item:** CLA.011
......@@ -4575,7 +4575,7 @@ create table hello. t (id int unsigned)
* **Content:** 为表添加注释能够使得表的意义更明确,从而为日后的维护带来极大的便利。
## 请为列添加默认值
## 请为列添加默认值
* **Item:** COL.004
......@@ -4583,7 +4583,7 @@ create table hello. t (id int unsigned)
* **Content:** 请为列添加默认值,如果是 ALTER 操作,请不要忘记将原字段的默认值写上。字段无默认值,当表较大时无法在线变更表结构。
## 列未添加注释
## 列未添加注释
* **Item:** COL.005
......@@ -4591,7 +4591,7 @@ create table hello. t (id int unsigned)
* **Content:** 建议对表中每个列添加注释,来明确每个列在表中的含义及作用。
## 未指定主键或主键非 int 或 bigint
## 未指定主键或主键非 int 或 bigint
* **Item:** KEY.007
......@@ -4599,7 +4599,7 @@ create table hello. t (id int unsigned)
* **Content:** 未指定主键或主键非 int 或 bigint,建议将主键设置为 int unsigned 或 bigint unsigned。
## 请为表选择合适的存储引擎
## 请为表选择合适的存储引擎
* **Item:** TBL.002
......@@ -4621,7 +4621,7 @@ WHERE
data >= ''
```
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......
......@@ -46,7 +46,7 @@ WHERE
## 不建议使用 SELECT * 类型查询
## 不建议使用 SELECT * 类型查询
* **Item:** COL.001
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册