Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Optimizing a Ratings Analysis Query | Real-World Query Optimization Scenarios
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Mastering SQL EXPLAIN and Query Planning

bookChallenge: Optimizing a Ratings Analysis Query

Tarea

Swipe to start coding

You are tasked with analyzing and optimizing a query that aggregates driver ratings and ride statistics. The goal is to improve the performance of a query that calculates, for each driver, the total number of rides and their average rating.

  • Use EXPLAIN to analyze the original query's execution plan.
  • Write and include an optimized query for better performance, using the available tables and data. You must provide the optimized query solution code; if it is missing or incomplete, the task will not pass.
  • Your optimized query must return, for each driver, their driver_id, first_name, last_name, the total number of rides (total_rides), and their average rating (avg_rating).
  • Ensure that drivers with no rides or ratings still appear in the results, with total_rides and avg_rating as zero.
  • Use EXPLAIN to show the execution plan of your optimized query.
  • The test will fail if your solution does not include a complete and correct optimized query.

Solución

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 6
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

close

bookChallenge: Optimizing a Ratings Analysis Query

Desliza para mostrar el menú

Tarea

Swipe to start coding

You are tasked with analyzing and optimizing a query that aggregates driver ratings and ride statistics. The goal is to improve the performance of a query that calculates, for each driver, the total number of rides and their average rating.

  • Use EXPLAIN to analyze the original query's execution plan.
  • Write and include an optimized query for better performance, using the available tables and data. You must provide the optimized query solution code; if it is missing or incomplete, the task will not pass.
  • Your optimized query must return, for each driver, their driver_id, first_name, last_name, the total number of rides (total_rides), and their average rating (avg_rating).
  • Ensure that drivers with no rides or ratings still appear in the results, with total_rides and avg_rating as zero.
  • Use EXPLAIN to show the execution plan of your optimized query.
  • The test will fail if your solution does not include a complete and correct optimized query.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 6
single

single

some-alt