【dbdao.com MySQL OCP认证专题】- MySQL 5.6 - OCP 考题讲解
dbdao吧
全部回复
仅看楼主
level 9
biotwang 楼主
获取MySQL 5.6 DBA ocp 需要通过如下的考试:
MySQL 5.6 Database Administrator 1Z0-883
如果是MySQL 5.6 Developer ocp 则需要通过:
MySQL 5.6 Developer 1Z0-882
考试通过,即可申请对应ocp认证
2015年10月23日 09点10分 1
level 9
biotwang 楼主
A simple master-to-slave replication is currently being used. The following information is extracted from the SHOW SLAVE STATUS output:
Last_SQL_Error: Error 'Duplicate entry '8' for key 'PRIMARY'' on query. Default database: 'mydb'.
Query: 'insert into mytable VALUES ('8', 'George')'
Skip_Counter: 0
Retrieved_Gtid_Set: 38f32e23480a7-32a1-c323f78067fd37821: 1-8
Auto_Position: 1
You execute a "SHOW CREATE TABLE mytable" on the slave:
CREATE TABLE 'mytable' (
'ID' int(11) NOT NULL DEFAULT '0',
'name' char(10) DEFAULT NULL,
PRIMARY KEY ('ID')
)
The table mytable on the slave contains the following:
You have issued a STOP SLAVE command. One or more statements are required before you can
issue a START SLAVE command to resolve the duplicate key error.
Which statement should be used?
A)
SET GLOBAL SQL_SKIP_SLAVE_COUNTER=1
B)
SET GTID_NEXT="CONSISTENCY";
BEGIN; COMMIT;
SET GTID_NEXT=" AUTOMATIC’;
C)
SET GLOBAL enforce_gtid_consistency=ON
D)
SET GTID_EXECUTED="38f32e23480a7-32a1-c323f78067fd37821 : 9";
E)
SET GTID_NEXT="38f32e23480a7-32a1-c323f78067fd37821 : 9";
BEGIN; COMMIT;
SET GTID_NEXT="AUTOMATIC";
--------------------------------------------------------------------
答案:E
分析:此题中使用的Replication是通过GTID实现的,因此
A错,因此GLOBAL SQL_SKIP_SLAVE_COUNTER=1对使用GTID进行的Replication无效
C错,因为GLOBAL enforce_gtid_consistency=ON是实现的前提。
由于GTID_NEXT的有效值为:
AUTOMATIC / ANONYMOUS / <UUID>:<NUMBER>
因此 B错
由于Retrieved_Gtid_Set: 38f32e23480a7-32a1-c323f78067fd37821: 1-8
因此已经收到主库事务1-8,因此报错是从第9个事务重复记录导致的,很有可能slave上的第8行被人为录入了,导致同步问题。
D错,因为GTID_EXECUTED表示已经执行完成的事务。
为了临时绕过这个问题,使用注入空事务(BEGIN; COMMIT; ) 代替完成第9个事务.
完成后GTID_EXECUTED才会变为"38f32e23480a7-32a1-c323f78067fd37821 : 9"
这时候重新SET GTID_NEXT="AUTOMATIC"; 重启slave后,开始从第10个事务开始同步。
2015年10月23日 09点10分 2
MySQL 认证题目虽然每年都会有变化,我们不可能都涵盖到。但是只要大家认真查阅对应题目相关的官方文档内容,并吃透题目后的知识体系。相信一定能安全通过考试。[呵呵]
2015年12月22日 12点12分
level 9
biotwang 楼主
Consider the following statement on a RANGE partitioned table:
ALTER TABLE orders DROP PARTITION p1, p3;
What is the outcome of executing the above statement?
A.
Only the first partition (p1) will be dropped as only one can be dropped at any time.
B.
All data in p1 and p3 partitions are removed, but the table definition remains unchanged.
C.
A syntax error will result as you cannot specify more than one partition in the same statement.
D.
All data in pi and p3 partitions are removed and the table definition is changed.
--------------------------------------------------------------------
答案:D
在删除部分分区后,可以使用show create table查看其定义也一并改变了
参考:
http://dev.mysql.com/doc/refman/5.7/en/alter-table-partition-operations.html
2015年10月24日 02点10分 3
此为动态图,请点入后细看~
2015年12月22日 12点12分
level 9
biotwang 楼主
3.
You inherit a legacy database system when the previous DBA, Bob, leaves the company. You are
notified that users are getting the following error:
mysql> CALL film_in_stock (40, 2, @count);
ERROR 1449 (HY000): The user specified as a definer ('bob'@'localhost') does not exist
How would you identify all stored procedures that pose the same problem?
A.
Execute SELECT * FROM mysql.routines WHERE DEFINER='bob@localhost';.
B.
Execute SHOW ROUTINES WHERE DEFINER='bob@localhost'.
C.
Execute SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE DEFINER='bob@localhost';.
D.
Execute SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER='bob' and HOST='localhost';.
E.
Examine the Mysql error log for other ERROR 1449 messages.
----------------------------------------------------------------------------------
答案:C
分析:routines表在库INFORMATION_SCHEMA下,因此A错。
可以登陆MySQL后,使用? show命令查看show语法。可知show无routine语句,B错。
可使用以下命令来查看routines:
pager less;
select * from information_schema.routines\G
可知C正确
INFORMATION_SCHEMA.PROCESSLIST表中仅显示了当前正在运行的线程信息,D错。
Mysql error log是对报错信息的记录,并不会有所有存储过程的记录,E错。
2015年10月25日 07点10分 4
level 9
biotwang 楼主
5.
ROW-based replication has stopped working. You investigate the error log file and find the following entries:
2013-08-27 14:15:47 9056 [ERROR] Slave SQL: Could not execute Delete_rows event on table test.t1; Can’t find record in ‘t1’, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event’s master log 56_master-bin.000003, end_log_pos 851, Error_code: 1032
2013-08-27 14:15:47 9056 [warning] Slave: Can’t find record in ‘t1’ Error_code: 1032
2013-08-27 14:15:47 9056 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with “SLAVE START”. We stopped at log ‘56_masterbin.000003’ position 684
Why did you receive this error?
A.
The slave SQL thread does not have DELETE privileges to execute on test.t1 table.s
B.
The table definition on the slave litters from the master.
C.
Multi-threaded replication slaves can have temporary errors occurring for cross database
updates.
D.
The slave SQL thread attempted to remove a row from the test.t1 table, but the row did not
exist.
-------------------------------------------------------------------------------------------
答案:D
分析:报错中说的非常明确Could not execute Delete_rows event on table test.t1; Can’t find record in ‘t1’,
这说明slave上这条记录已经被人为删除了,导致Row-Based Replication进行同步删除的时候,找不到这条记录。ABC选项都和此报错以及所问问题无关。
2015年10月27日 02点10分 6
level 9
biotwang 楼主
6.
mysqldump was used to create a single schema backup;
Shell> mysqldump –u root –p sakila > sakila2013.sql
Which two commands will restore the sakila database without interfering with other running
database?
A.
Mysql> USE sakila; LOAD DATA INFILE 'sakila2013.sql';
B.
Shell> mysql –u root –p sakila < sakila2013.sql
C.
Shell> mysqlimport –u root –p sakila sakila2013.sql
D.
Shell> mysql –u root -p –e 'use sakila; source sakila2013.sql'
E.
Shell> mysql –u root –p –silent < sakila2013.sql
--------------------------------------------------------------------------------
答案:B
分析:
A错,load data infile针对的是select ... into oufile输出的表数据文件,其文件中不含有插入执行语句,仅含有数据。而mysqldump导出的文件包含的数据是以可执行sql语句实现的。
C错,因此mysqlimport是类似于load data infile语句功能的shell命令行工具,因此对应倒入的文件都应该是非sql语句执行的纯表数据文件。
我们看到mysqldump在未使用--database项导出时,并未在文件中使用create database语句。
当导入数据库dump文件,你需要在命令中指定数据库名,即use db_name进入此库:
shell> mysql db_name < dump.sql
因此B正确
mysql -e 可用于执行语句,但是mysql客户端语句需要使用分号作为终止符发给服务端,因此每个语句后都需要使用分号,D错误。
如果D为Shell> mysql –u root -p –e 'use sakila; source sakila2013.sql;' 则正确。
E错. mysql命令项使用中,短项使用单横杠,长命令项使用双横杠 -silent项应该时候双横杠,因此错。
参考:
http://dev.mysql.com/doc/refman/5.7/en/load-data.html
http://dev.mysql.com/doc/refman/5.7/en/mysqlimport.html
http://dev.mysql.com/doc/refman/5.7/en/mysql.html
2015年10月28日 03点10分 7
由于无法准确定位出题者意图,是否纠结此分号,还是仁者见仁,智者见智[黑线]
2015年12月30日 03点12分
我过几天考试,如果有这道题我会在真题上再确认下。
2016年06月12日 04点06分
我也纠结,题目说哪两个命令。要多选。我怀疑是不是D印制错了。要不然只有B一个选项啊。
2016年07月29日 02点07分
[汗]
2016年11月14日 05点11分
level 9
biotwang 楼主
Consider the Mysql Enterprise Audit plugin.
You are checking user accounts and attempt the following query:
Mysql> SELECT user, host, plugin FROM mysql.users;
ERROR 1146 (42S02): Table ‘mysql.users’ doesn’t exist
Which subset of event attributes would indicate this error in the audit.log file?
A.
NAME=”Query”
STATUS=”1146”
SQLTEXT=”select user,host from users”/>
B.
NAME=”Error”
STATUS=”1146”
SQLTEXT=”Error 1146 (42S02): Table ‘mysql.users’ doesn’t exist”/>
C.
NAME=”Query”
STATUS=”1146”
SQLTEXT=” Error 1146 (42S02): Table ‘mysql.users’ doesn’t exist”/>
D.
NAME=”Error”
STATUS=”1146”
SQLTEXT=”select user,host from users”/>
E.
NAME=”Error”
STATUS=”0”
SQLTEXT=”Error 1146 (42S02): Table ‘mysql.users’ doesn’t exist”/>
---------------------------------------------------------
答案:A
分析:
注意:MySQL Enterprise Audit是包含在MySQL企业版中的一个扩展插件,因此如果你在学习时使用的是社区版的MySQL,那你是无法实验的。
因为它需要在环境变量plugin_dir对应目录下存在audit_log.so插件文件。
从选择答案中可知,Audit log中使用的是旧格式进行的记录。
由于SQLTEXT仅在NAME为Query或Execute时,才会有出现,且NAME不存在Error状态。因此B,D,E错。
而SQLTEXT仅存放所使用的SQL语句。而返回的状态存放在STATUS下,0为成功,非0为报错号,因此A对C错。
参考:
http://dev.mysql.com/doc/refman/5.7/en/audit-log-plugin.html
http://dev.mysql.com/doc/refman/5.7/en/audit-log-file.html
2015年10月29日 09点10分 8
level 9
biotwang 楼主
8.
Which query would you use to find connections that are in the same state for longer than 180 seconds?
A.
SHOW FULL PROCESSLIST WHERE Time > 180;
B.
SELECT * FROM INFORMATION_SCHEMA.EVENTS SHERE STARTS < (DATE_SUB(NOW(), INTERVAL 180 SECOND));
C.
SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE STATE < (DATE_SUB(NOW(), INTERVAL 180 SECOND));
D.
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE TIME > 180;
-------------------------------------------------
答案:D
分析:
你可以使用 help show;命令来查看其语法可知:
SHOW [FULL] PROCESSLIST
此语法后面不可以跟where语句,因此A错。
INFORMATION_SCHEMA.EVENTS表显示的是计划的作业,和连接保持的状态时间无关,B错。
INFORMATION_SCHEMA.SESSION_STATUS表显示的是当前会话的变量及其变量值,和状态信息无关,C错。
INFORMATION_SCHEMA.PROCESSLIST显示了当前的连接情况,状态,以及状态保持的时间,实际上show processlist也是查看的这张表,不过直接使用select可以使用where语句,D正确。
参考:
http://dev.mysql.com/doc/refman/5.7/en/information-schema.html
2015年10月30日 03点10分 9
level 13
打一下广告 我们dbDao.com 的MySQL OCP考证群 可以加 QQ群号:
146959374
点击链接加入群【dbDao.com MySQL学习1群】:http://jq.qq.com/?_wv=1027&k=YNiOnz
2015年10月31日 12点10分 10
level 13
2015年10月31日 12点10分 11
level 9
biotwang 楼主
A database exists as a read-intensive server that is operating with query_cache_type =
DEMAND.
The database is refreshed periodically, but the resultset size of the queries does not fluctuate.
—-Note the following details about this environment:
A web application uses a limited set of queries.
The Query Cache hit rate is high.
All resultsets fit into the Query Cache.
All queries are configured to use the Query Cache successfully.
The response times for queries have recently started to increase. The cause for this has correctly
been identified as the increase in the number of concurrent users accessing the web service.
Based solely on the information provided, what is the most likely cause for this slowdown at the
database level?
A.
The Query Cache is pruning queries due to an increased number of requests.
B.
Query_cache_min_res_unit has been exceeded, leading to an increased performance
overhead due to additional memory block lookups.
C.
Mutex contention on the Query Cache is forcing the queries to take longer due to its singlethreaded nature.
D.
The average resultset of a query is increasing due to an increase in the number of users
requiring SQL statement execution.
---------------------------------------------------------------------------------------------------------
答案:C
分析:这是一个读密集型数据库,数据库会在一段时间后刷新,但是其查询的结果集大小波动不大。而所有结果集都在Query Cache中,且网页应用使用一套有限的查询语句。且Query Cache hit rate很高。
因此A,D错,请求通过的应用查询,查询语句数量有限,结果集都能放在Query Cache中,相同查询语句的请求不会增多Query Cache中的资源的占用,因此清理查询并非主要矛盾。
B也错,因此Query_cache_min_res_unit设置过大,仅会造成Query Cache中碎片过多。如果请求的结果集都能在Query Cache中,这就和碎片没什么关系了。
C正确,尽管官方文档中未大量解释Query Cache Mutex争用问题,在线程运行查询语句时,会在Query Cache中先获取Mutex锁,之后开始查询匹配的查询语句和结果集。如果找到后返回结果。
如果未找到匹配,在执行查询后,需要将查询语句和结果集插入Query Cache中,这也会需要获取锁。尽管这个时间所需非常短,但是在读密集的情况下,资源争用会导致线程排队等待现象。
参考:
http://dev.mysql.com/doc/refman/5.7/en/query-cache.html
http://dev.mysql.com/doc/refman/5.7/en/query-cache-configuration.html
2015年11月02日 03点11分 12
此为第9题。
2015年11月02日 03点11分
level 9
biotwang 楼主
10.
You have a login-path named "adamlocal" that was created by using the mysql_config_editor
command.
You need to check what is defined for this login_path to ensure that it is correct for you
deployment.
You execute this command:
$ mysql_config_editor print –login-path=adamlocal
What is the expected output of this command?
A.
The command prints all parameters for the login-path. The password is printed in plain text.
B.
The command prints all parameters for the login-path. The password is shown only when you
provide the --password option.
C.
The command prints all parameter for the login-path. The password is replaced with stars.
D.
The command prints the encrypted entry for the login-path. The is only possible to see if an
entry exists.
---------------------------------------------------
答案:C
分析:
mysql_config_editor工具命令用于建立外部登陆文件,一般由mysql客户端或应用来使用,好处在于登陆时免去输入登陆密码,密码已经被保存在了登陆文件中。在环境变量MYSQL_TEST_LOGIN_FILE未设置的情况下,mysql_config_editor默认文件名为.mylogin.cnf,且文件保存在执行此命令的用户home目录下。
登陆文件建立后,可直接使用以下命令登陆:
shell> mysql --login-path=login-path
当然,--login-path的默认值为client,因此如果你使用mysql_config_editer set --login-path=client 来进行用户密码设置设置,那么登陆所设用户的时候,连--login-path也可不用了:
shell> mysql
A, D错,因为不管如何,你都看不到密码的,密码被加密保存后,使用mysql_config_editor print会将密码替代以星号显示。
B错,使用mysql_config_editor --help可知在参数项中没有此--password项,且通过参考文档可知--password是用于设置密码而非显示密码的。
C正确。
参考:
http://dev.mysql.com/doc/refman/5.7/en/mysql-config-editor.html
2015年11月03日 07点11分 13
此为动态图,请点入后细看~
2015年12月22日 12点12分
做的很细。感谢感谢[大拇指]
2016年06月12日 04点06分
level 9
biotwang 楼主
11
You are using replication and the binary log files on your master server consume a lot of disk space.
Which two steps should you perform to safely remove some of the older binary log files?
A.
Ensure that none of the attached slaves are using any of the binary logs you want to delete.
B.
Use the command PURGE BINARY LOGS and specify a binary log file name or a date and time to remove unused files.
C.
Execute the PURGE BINARY LOGE NOT USED command.
D.
Remove all of the binary log files that have a modification date earlier than today.
E.
Edit the .index file to remove the files you want to delete.
---------------------------------------------------------------------------
答案:AB
分析:
A是必须要保证的,你的删除的肯定不能正被slave使用啦。
PURGE LOGS语法PURGE { BINARY | MASTER } LOGS { TO 'log_name' | BEFORE datetime_expr },所做操作会对.index文件进行自动更新。因此B正确,E错。
C错,无此语法。
D错,具体清理到什么位置需要按照SHOW SLAVE STATUS来查看,而不是武断地确定删除早于今天的binary log文件。
参考:
http://dev.mysql.com/doc/refman/5.7/en/purge-binary-logs.html
2015年11月05日 02点11分 14
level 9
biotwang 楼主
12.
Which two statements are true about InnoDB auto-increment locking?
A.
The auto-increment lock can be a table-level lock.
B.
InnoDB never uses table-level locks.
C.
Some settings for innodb_autoinc_lock_mode can help reduce locking.
D.
InnoDB always protects auto-increment updates with a table-level lock.
E.
InnoDB does not use locks to enforce auto-increment uniqueness.
---------------------------------------------------------------------------
答案:A, C
分析:
auto-increment的AUTO-INC锁是一个表级锁,因此A正确,B和E错误,。
C正确,根据数据库参数innodb_autoinc_lock_mode的设置,插入操作会根据模式和所用语句的不同选用相应的锁。innodb_autoinc_lock_mode = 2的时候,将不使用表级锁和轻量mutex锁,不过在基于语句复制(SBR: Statement Based Replication)时,会有交错序列风险。
参考:
http://dev.mysql.com/doc/refman/5.7/en/innodb-auto-increment-handling.html
http://dev.mysql.com/doc/refman/5.7/en/innodb-auto-increment-configurable.html
2015年11月05日 03点11分 15
level 9
biotwang 楼主
14.
You execute the following statement in a Microsoft Windows environment. There are no conflicts in the path name definitions.
C: \> mysqld –-install Mysql56 –-defaults–file=C:\my–opts.cnf
What is the expected outcome?
A.
Mysqld acts as an MSI installer and installs the Mysql 5.6 version, with the c:\my-opts.cnf
configuration file.
B.
Mysql is installed as the Windows service name Mysql56, and uses c:\my-opts.cnf as the
configuration file
C.
An error message is issued because –-install is not a valid option for mysqld.
D.
A running Mysql 5.6 installation has its runtime configuration updated with the server variables
set in c:\my-opts.cnf.
------------------------------------------
答案:B
分析:
首先mysqld是作为MySQL服务端主程序来运行的,它并不负责MSI安装的过程,因此A错。
通过mysqld --install可以进行Windows服务注册,同时--defaults-file用于设置启动服务端时使用的配置文件,B正确。
请注意--install命令项仅存在于Windows版MySQL的mysqld命令中,如果你是在Linux上安装MySQL是无法找到mysqld对应的--install命令项的。
C错误,因为其对于Windows版的mysqld是有效项。
D错,因此这命令不是用于安装时的配置。
参考:
http://dev.mysql.com/doc/refman/5.7/en/windows-start-service.html
2015年11月07日 06点11分 17
level 9
biotwang 楼主
17.
Assume that you want to know which Mysql Server options were set to custom values.
Which two methods would you use to find out?
A.
Check the configuration files in the order in which they are read by the Mysql Server and compare them with default values.
B.
Check the command-line options provided for the Mysql Server and compare them with default values.
C.
Check the output of SHOW GLOBAL VARIABLES and compare it with default values.
D.
Query the INFORMATION_SCHEMA.GLOBAL_VARIABLES table and compare the result with default values.
答案:C, D (for MySQL 5.6) C (for MySQL 5.7)
分析;
MySQL Server配置项由多处设置组成,由于Server的主程序为mysqld,因此其命令项设置也主要是看mysqld对应的项的设置。
在命令项设置后,启动后相应项反应在数据库上,就是那些Global Variables全局变量了,当用户会话访问时,其Session Variables则会copy自全局变量值,之后用户可以根据需要使用SET命令来修改会话变量。
当然如果有足够的权限,用户也可以修改全局变量,不过这种修改仅应用于正在运行MySQL Server,且对之后新登陆会话有效,一旦Server重启就打回原形了。
此题中,主要是希望查看启动后,使用的全局变量和其默认值修改情况,一般在启动初始化时,我们可以提前通过mysqld的命令行项上直接修改,或使用配置文件来进行启动时候的项的默认修改。
但是A, B都是错的,因为你无法确认MySQL Server的全局变量在启动后是否有人为被再次修改过。
C正确,因为show global variables可以了解当前所有全局变量值,从而和默认值进行比较。请注意:show variables指的是查看当前会话变量,因此一定要加上global。
D在MySQL 5.6版本中正确,因为其global variables值存放于此表中。不过在5.7版本,GLOBAL_VARIABLES这张表被移至performance_schema下,原先INFORMATION_SCHEMA.GLOBAL_VARIABLES将成为空表并被弃用。
参考:
http://dev.mysql.com/doc/refman/5.7/en/option-files.html
http://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html
2015年11月12日 03点11分 20
level 9
biotwang 楼主
18.
You install a copy of Mysql 5.6.13 on a brand new Linux server by using RPM packages. The server starts successfully as verified by the following commands:
$ pidof mysqld
3132
$ tail – n2 /var/lib.mysql/hostname.err
2013-08-18 08:18:38 3132 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.13-enterprise-commercial-advanced' socket: '/tmp/mysql.sock' port: 3306
Mysql Enterprise Server – Advanced Edition (Commercial)
You attempt to log in as the root user with the following command:
$ mysql –u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Which statement is true about this scenario?
A.
The RPM installation script sets a default password of password for new installations.
B.
The local root user must log in with a blank password initially: mysql –u root –p.
C.
New security measures mean that the mysql_secure_installation script must be run first on all new installations.
D.
The mysql_install_db post-installation script used –-random-passwords.
--------------------------------------
答案:D
分析:
MySQL5.6 Linux RPM包安装中会调用带有--random-passwords参数项的mysql_install_db脚本命令, 为root用户生成一个随机密码,并保存在$HOME/.mysql_secret文件中。
A错,生成的是一个随机密码,而非默认密码。B错,因为本地root用户已经有一个生成的密码了,因此空密码是不能登陆成功的。
C错,mysql_secure_installation是一个非必要脚本,在MySQL安装完成后,你可以运行此脚本来进一步增强其安全策略。
参考:
http://dev.mysql.com/doc/refman/5.6/en/linux-installation-rpm.html
http://dev.mysql.com/doc/refman/5.6/en/mysql-secure-installation.html
2015年11月13日 06点11分 21
level 9
biotwang 楼主
22.
Consider the query:
Mysql> SET @run = 15;
Mysql> EXPLAIN SELECT objective, stage, COUNT(stage)
FROM iteminformation
WHERE run=@run AND objective='7.1'
GROUP BY objective,stage
ORDER BY stage;
The iteminformation table has the following indexes;
Mysql> SHOW INDEXES FROM iteminformation:
This query is run several times in an application with different values in the WHERE clause in a growing data set.
What is the primary improvement that can be made for this scenario?
A.
Execute the run_2 index because it has caused a conflict in the choice of key for this query.
B.
Drop the run_2 index because it has caused a conflict in the choice of key for this query.
C.
Do not pass a user variable in the WHERE clause because it limits the ability of the optimizer to use indexes.
D.
Add an index on the objective column so that is can be used in both the WHERE and GROUP BY operations.
E.
Add a composite index on (run,objective,stage) to allow the query to fully utilize an index.
答案:E
分析:首先我们需要了解EXPLAIN命令执行后的输出含义,对应查询中Possible_Keys显示在查询时可使用Run和Run_2这两个索引来优化查询,Keys列则表明最终执行计划选择使用Run_2索引。
通过SHOW INDEXES FROM <table>命令,我们可以了解此表所有的索引,这里我们知道有Run(Run, Name)索引和Run_2(Run Stage)索引。
MySQL建立的联合索引,在利用这些索引时,你需要遵循leftmost prefix index(最左前缀索引)原则,即当你有一个索引为(col1, col2, col3),在查询时,查询条件中对(col1), (col1, col2)或(col1, col2, col3)
进行查询时可以使用到此索引。
由于Where中有run=@run,因此,索引Run和Run_2都满足被利用的条件,由于GROUP BY按规则无法利用这些索引,而ORDER BY则可以进一步利用stage索引,因此最终优化器选择使用Run_2索引。
A, B错,因此这种冲突说法不成立,因为索引的选择是由优化器选择的结果。C错,使用变量并不会对优化器使用索引进行限制。
D错,因此仅对objective列建立索引,并不会被GROUP BY使用。
E正确,因为建立(run,objective,stage)索引,此查询满足GROUP BY的Tight Index Scan规则,可以使用此索引提高查询性能。
参考:
http://dev.mysql.com/doc/refman/5.6/en/explain-output.html
http://dev.mysql.com/doc/refman/5.7/en/show-index.html
http://dev.mysql.com/doc/refman/5.6/en/group-by-optimization.html
http://dev.mysql.com/doc/refman/5.6/en/order-by-optimization.html
2015年11月17日 05点11分 25
写的很好。感谢感谢!
2016年06月13日 03点06分
level 9
biotwang 楼主
23.
Consider typical High Availability (HA) solutions that do not use shared storage.
Which three HA solutions do not use shared storage?
A.
MySQL Replication
B.
Distributed Replicated Block Device (DRBD) and Mysql
C.
Windows Cluster and MySQL
D.
Solaris Cluster and MySQL
E.
MySQL NDB Cluster
答案:A, B, E
分析:从图中的Shared Nothing我们就可以知道MySQL Replication,MySQL Fabric,DRBD,MySQL Cluster都符合要求,既然什么都不会共享使用,那么存储也一样不会被共享啦。
Windows Cluster和Solaris Cluster都类似于第二,三张图所示,是共享存储的,因此CD被排除。
MySQL Replication故名思意是复制,复制一个备库存储。DRBD是在系统级别的同步复制技术,数据库是不共享的。
而MySQL NDB Cluster可以通过不同节点组来分散数据达到不共享存储的目的的,如第四张图。
参考:
http://dev.mysql.com/doc/refman/5.7/en/replication.html
http://dev.mysql.com/doc/refman/5.7/en/ha-overview.html
2015年11月18日 10点11分 27
DRBD HA由于其本身缺点,在MySQL最新的官方文档中,其内容已经被拿掉了。将来更多请关注MySQL Fabric
2016年02月23日 03点02分
level 9
biotwang 楼主
24.
Which three statements are characteristic of the MEMORY storage engine?
A.
Each table is represented on disk as an .frm file.
B.
Each table has a corresponding.MYI and .MYD file.
C.
It can support foreign keys.
D.
It cannot contain text or BLOB columns.
E.
Table contents are not saved if the server is restarted.
F.
It can support transactions
答案:A, D, E
分析:以MEMORY引擎建立的每张表都对应了一个以.frm为后缀的表定义文件。.MYI和.MYD对应的是以MyISAM引擎建立的的表的索引及数据文件。
MEMORY引擎不支持外键,不支持事务,也不支持TEXT和BLOB类型列。表会在服务端重启时被清空,一般作为临时工作及从其他表抽取的只读数据存放地处理。
参考:
http://dev.mysql.com/doc/refman/5.6/en/memory-storage-engine.html
2015年11月19日 03点11分 28
1 2 3 4 尾页