Access Millions of academic & study documents

Sampdb Queries

Content type
User Generated
Subject
MySQL
School
American University
Type
Homework
Showing Page:
1/6

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/6

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/6

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 6 pages?
Access Now
Unformatted Attachment Preview
Question 1 INNER JOIN Question 1 OUTER JOIN Question 1 SUBQUERY Question 2 Question 3: Query Optimizer The query optimizer is useful in the situation where the database is too large and can result in slow performance if query optimization is not utilized in database design. To be able to determine the amount of time and resources needed to execute a query, ‘explain’ statement can be prepended to the query. The information returned shows how MySQL executes a given query. This information can be helpful in figuring out fields that need to be indexed in a database. An illustration shown above shows that the first query in question 1 has got a key ‘student_id’ in scores table which references the same key in the student table and only 2 rows can be searched to return the required results. Therefore, MYSQL will first execute the inner query in order to efficiently return the expected results. It is a good idea to index all the columns found under GROUP BY, WHERE and ORDER BY clauses to be able to query the database more efficiently. Subsequently, the following screenshot shows that ‘student_id’ in scores table has an index hence only 1 row will be searched against 173 rows in the second table. On the contrary, the search will go through 173 rows in the subquery in order to return the needed result as shown below. In order to improve on performance, an index has to be created on the score field of the scores table. The following query will take considerably m ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4