Help Center > > Developer Guide> Query Performance Optimization> Optimization Cases> Case: Creating an Appropriate Index

Case: Creating an Appropriate Index

Updated at:Jul 15, 2020 GMT+08:00

Symptom

Query the information about all personnel in the sales department.

1
2
3
4
5
6
7
SELECT staff_id,first_name,last_name,employment_id,state_name,city 
FROM staffs,sections,states,places 
WHERE sections.section_name='Sales' 
AND staffs.section_id = sections.section_id 
AND sections.place_id = places.place_id 
AND places.state_id = states.state_id 
ORDER BY staff_id;

Optimization Analysis

The original execution plan is as follows before creating the places.place_id and states.state_id indexes:

The optimized execution plan is as follows (two indexes have been created on the places.place_id and states.state_id columns):

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel