Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

Avoiding NULL in columns may make queries simpler.(a) True(b) FalseI had been asked this question in my homework.This interesting question is from Choosing Data Types for Efficient Queries topic in section Query Optimization of MySQL

Answer»

Correct ANSWER is (a) True

To explain: In MYSQL, avoiding the NULL in columns may make the queries simpler, since it is not required to check for NULL as a special case. Simpler queries generally can be PROCESSED more quickly.

52.

To maintain performance of tables having variable length rows, which statement is used?(a) MAINTAIN TABLE(b) BALANCE TABLE(c) ADJUST TABLE(d) OPTIMIZE TABLEI got this question by my school principal while I was bunking the class.My enquiry is from Choosing Data Types for Efficient Queries in chapter Query Optimization of MySQL

Answer»

The correct option is (d) OPTIMIZE TABLE

Best explanation: In the VARIABLE LENGTH ROWS, there is more FRAGMENTATION of the table on which many DELETES or updates are performed. OPTIMIZE TABLE is run periodically to maintain performance.

53.

To convert a string to an int, the function is _________________(a) INET_ATON()(b) INET_NTOA()(c) INET_ITOS()(d) INET_STOI()I got this question in semester exam.My enquiry is from Choosing Data Types for Efficient Queries in chapter Query Optimization of MySQL

Answer»

Correct choice is (a) INET_ATON()

The EXPLANATION: In MYSQL, the function used to convert a STRING to an integer is INET_ATON(). On the other hand, the function INET_NTOA() converts a string to the corresponding integer VALUE.

54.

To convert an int to string, the function is _________________(a) INET_ATON()(b) INET_NTOA()(c) INET_ITOS()(d) INET_STOI()The question was posed to me by my school teacher while I was bunking the class.This intriguing question comes from Choosing Data Types for Efficient Queries in section Query Optimization of MySQL

Answer» CORRECT answer is (b) INET_NTOA()

The best I can EXPLAIN: In MySQL, the function USED to CONVERT an integer to a string is INET_NTOA(). On the other hand, the function INET_ATON() converts a string to the corresponding integer value.
55.

Calculations involving numbers are faster than those involving string.(a) True(b) FalseI had been asked this question during a job interview.I need to ask this question from Choosing Data Types for Efficient Queries in section Query Optimization of MySQL

Answer»

The correct option is (a) True

To explain I would say: Numbers can be compared in a single operation while STRING COMPARISONS INVOLVE several byte by byte or character by character comparisons. As the strings BECOME longer, the performance gets poor.

56.

The optimizer_prune_level is set by default.(a) True(b) FalseThis question was addressed to me during a job interview.The above asked question is from MySQL Query Optimizer in section Query Optimization of MySQL

Answer»

Right option is (a) True

Best explanation: In MYSQL, the optimizer_prune_level is on by default. This variable tells the OPTIMIZER to skip certain plans based on ESTIMATES of the NUMBER of rows ACCESSED for each table.

57.

Which system variable tells how far into the rest of each incomplete plan the optimizer should look to evaluate whether it should be expanded further?(a) optimizer_prune_level(b) optimizer_search_depth(c) optimizer_search(d) optimizer_pruneI have been asked this question at a job interview.I would like to ask this question from MySQL Query Optimizer in division Query Optimization of MySQL

Answer»

The correct option is (B) optimizer_search_depth

For explanation: In MySQL, the optimizer_search_depth SYSTEM variable tells how FAR into the “future” of each incomplete plan the optimizer should look to EVALUATE whether it should be EXPANDED further.

58.

Which system variable tells the optimizer to skip certain plans based on estimates of the number of rows accessed for each table?(a) optimizer_prune_level(b) optimizer_search_depth(c) optimizer_search(d) optimizer_pruneThis question was posed to me in an online interview.I'd like to ask this question from MySQL Query Optimizer topic in chapter Query Optimization of MySQL

Answer» CORRECT ANSWER is (a) optimizer_prune_level

The explanation is: The optimizer_prune_level VARIABLE tells the optimizer to skip CERTAIN plans based on estimates of the number of rows accessed for each table. This option is kept on by default.
59.

Which of these comparisons is slowest?(a) INT/INT(b) INT/BIGINT(c) BIGINT/BIGINT(d) All are of same speedThis question was addressed to me in homework.I want to ask this question from MySQL Query Optimizer topic in portion Query Optimization of MySQL

Answer»

The correct OPTION is (B) INT/BIGINT

Explanation: On COMPARING indexed columns, identical data TYPES will give better performance than dissimilar types. So an INT/INT or BIGINT/BIGINT comparison is faster than an INT/BIGINT comparison.

60.

Which statement is used to force the optimizer to use tables in a particular order?(a) FORCE INDEX(b) USE INDEX(c) IGNORE INDEX(d) STRAIGHT_JOINI have been asked this question during an online interview.The question is from MySQL Query Optimizer topic in portion Query Optimization of MySQL

Answer»

Right answer is (d) STRAIGHT_JOIN

For explanation I would SAY: STRAIGHT_JOIN is used to force the optimizer to use TABLES in a particular ORDER. The MYSQL optimizer by default considers itself free to DETERMINE the order in which to scan tables most quickly.

61.

Which statement is used to verify optimizer operation?(a) ANALYZE(b) VERIFY(c) EXPLAIN(d) SHOWI have been asked this question at a job interview.The doubt is from MySQL Query Optimizer topic in section Query Optimization of MySQL

Answer» CORRECT OPTION is (c) EXPLAIN

Explanation: The EXPLAIN STATEMENT in MYSQL can tell whether the INDEXES are being used or not. This information is helpful when different ways of writing a statement need to be tested.
62.

To perform analysis of key values by the server, the statement used is __________(a) ANALYZE KEYS(b) ANALYZE TABLE(c) PERFORM ANALYSIS(d) PERFORM TABLE ANALYSISThis question was addressed to me in an interview for internship.My question is taken from MySQL Query Optimizer topic in division Query Optimization of MySQL

Answer»

Right choice is (b) ANALYZE TABLE

Easy explanation: In MySQL, for the MyISAM and InnoDB tables, the server can be TOLD to PERFORM an ANALYSIS of key values by issuing the ANALYZE TABLE STATEMENT. It helps in knowing about query optimization.

63.

To check how MySQL would execute a SELECT query, which statement is used?(a) TELL(b) SHOW(c) DISPLAY(d) EXPLAINThis question was addressed to me by my school teacher while I was bunking the class.My question is based upon MySQL Query Optimizer topic in section Query Optimization of MySQL

Answer»

Right option is (d) EXPLAIN

Explanation: In MySQL, by issuing an EXPLAIN STATEMENT MySQL DISPLAYS some information about how it would execute a SELECT query without actually executing it. It is prefixed with the query.

64.

The slow query log is written as __________(a) numbers(b) text(c) image(d) graphI have been asked this question in semester exam.My query is from Using Indexing in portion Query Optimization of MySQL

Answer»

Right option is (b) TEXT

Best explanation: In MySQL, the SLOW query log is written as text, so it is viewable with any file DISPLAY program. The mysqldumpslow utility can also be USED to summarize the contents of the same.

65.

The slow query log can be used to identify queries that may be performing badly.(a) True(b) FalseThis question was posed to me in an online quiz.The query is from Using Indexing in portion Query Optimization of MySQL

Answer»

Correct answer is (a) True

To ELABORATE: In MySQL, the slow QUERY LOG is USED to identify queries that may be performing badly. This log can help find the queries that MIGHT benefit from indexing. The slow query log is written as text.

66.

For a table having 4 columns, the number of columns to which hash function is applied when using hash indexes is __________(a) 1(b) 2(c) 3(d) 4The question was asked in homework.I want to ask this question from Using Indexing in chapter Query Optimization of MySQL

Answer»

Right answer is (d) 4

To elaborate: In MySQL, for the hash indexes, a hash FUNCTION is applied to each of the column VALUES. The resulting hash values are stored in the index and USED to PERFORM lookups on it.

67.

If a column contains 7 values and 6 distinct values, the cardinality is __________(a) 7(b) 6(c) 13(d) 1I had been asked this question in an online quiz.This interesting question is from Using Indexing topic in chapter Query Optimization of MySQL

Answer» RIGHT choice is (b) 6

Best explanation: In MySQL, the cardinality of a column is the number of distinct values that it CONTAINS. A column that contains the values 1, 2, 3, 4, 4, 5, 6 has a cardinality of six and not seven.
68.

In a single table (with 10 columns) join query the number of values needed to examine per column is __________(a) 1(b) 10(c) 0(d) 2I had been asked this question by my college professor while I was bunking the class.This is a very interesting question from Using Indexing in division Query Optimization of MySQL

Answer» RIGHT ANSWER is (b) 10

For EXPLANATION I would say: For indexing in the context of performing joins, in a single table query, the number of values that are needed to be examined per COLUMN is the number of rows in the table.
69.

The data rows of a MyISAM table are stored in __________(a) data file(b) index file(c) log file(d) error fileI had been asked this question in a national level competition.My doubt is from Using Indexing in division Query Optimization of MySQL

Answer»

Correct CHOICE is (a) data file

The EXPLANATION is: The data rows of the MyISAM table are stored in a data file and the INDEX VALUES are stored in a SEPARATE index file. In MySQL, for a MyISAM table, there can be more than one indexes.

70.

The maximum number of indexes on MyISAM table is __________(a) 0(b) 1(c) 2(d) more than 1This question was addressed to me in class test.This is a very interesting question from Using Indexing topic in division Query Optimization of MySQL

Answer»

Correct choice is (d) more than 1

To elaborate: In MySQL, for a MYISAM table, there can be more than ONE indexes. The DATA rows of the MyISAM table are stored in a data file and the index values are stored in a SEPARATE index file.

71.

Using indexes optimizes query performance.(a) True(b) FalseI had been asked this question in a national level competition.The query is from Using Indexing topic in section Query Optimization of MySQL

Answer»

Correct choice is (a) True

To explain I WOULD say: In MySQL, there are MANY techniques available for optimizing queries. Indexing is the most USEFUL. GENERALLY the one thing that makes the most DIFFERENCE is the proper use of indexes.