Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Query Optimization | Query optimization.Indexes
Advanced Techniques in SQL
course content

Conteúdo do Curso

Advanced Techniques in SQL

Advanced Techniques in SQL

1. ACID
2. Query optimization.Indexes
3. Some Additional Topics

Challenge: Query Optimization

Let's discover two tables: BankAccounts and one additional table named Transactions.

BankAccounts table

Transactions table

Assume we want to retrieve only the account numbers that have performed at least one transaction.

In this task, we have a query that is not optimized. Your task is to rewrite it in a more optimal way.

Here is a list of the main query rewriting techniques to enhance optimization:

  1. Explicitly Specify Columns: Instead of using the asterisk (*) wildcard, explicitly mention column names in queries for better performance, readability, and maintainability;
  2. Minimize Subqueries: Reduce the use of subqueries to optimize query performance. Consider alternatives like joins or derived tables to avoid complexity and overhead;
  3. Avoid Repeated IN Operators: Limit the use of the IN operator in queries to prevent performance impact. Instead, consider using JOIN or EXISTS clauses for more efficient execution plans;
  4. Organize Joins Logically: Start SQL joins with the main table and then join with related tables to optimize query organization and database engine optimization;
  5. Use Restrictive WHERE Conditions: Improve query performance by including restrictive conditions in the WHERE clause to filter rows and enhance execution speed;
  6. Refactor Code into Stored Procedures or Functions: Encapsulate repetitive code segments into stored procedures or user-defined functions for code reusability, modularity, and easier maintenance. These can reduce redundancy and optimize SQL queries.

Tarefa

Please rewrite the query more optimally. Pay attention to the fact that we need to get only account numbers that have performed at least one transaction (transferred money to another account) sorted in ascending order.

Note

Use LEFT or INNER join type to complete this task.

Tarefa

Please rewrite the query more optimally. Pay attention to the fact that we need to get only account numbers that have performed at least one transaction (transferred money to another account) sorted in ascending order.

Note

Use LEFT or INNER join type to complete this task.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 2. Capítulo 7
toggle bottom row

Challenge: Query Optimization

Let's discover two tables: BankAccounts and one additional table named Transactions.

BankAccounts table

Transactions table

Assume we want to retrieve only the account numbers that have performed at least one transaction.

In this task, we have a query that is not optimized. Your task is to rewrite it in a more optimal way.

Here is a list of the main query rewriting techniques to enhance optimization:

  1. Explicitly Specify Columns: Instead of using the asterisk (*) wildcard, explicitly mention column names in queries for better performance, readability, and maintainability;
  2. Minimize Subqueries: Reduce the use of subqueries to optimize query performance. Consider alternatives like joins or derived tables to avoid complexity and overhead;
  3. Avoid Repeated IN Operators: Limit the use of the IN operator in queries to prevent performance impact. Instead, consider using JOIN or EXISTS clauses for more efficient execution plans;
  4. Organize Joins Logically: Start SQL joins with the main table and then join with related tables to optimize query organization and database engine optimization;
  5. Use Restrictive WHERE Conditions: Improve query performance by including restrictive conditions in the WHERE clause to filter rows and enhance execution speed;
  6. Refactor Code into Stored Procedures or Functions: Encapsulate repetitive code segments into stored procedures or user-defined functions for code reusability, modularity, and easier maintenance. These can reduce redundancy and optimize SQL queries.

Tarefa

Please rewrite the query more optimally. Pay attention to the fact that we need to get only account numbers that have performed at least one transaction (transferred money to another account) sorted in ascending order.

Note

Use LEFT or INNER join type to complete this task.

Tarefa

Please rewrite the query more optimally. Pay attention to the fact that we need to get only account numbers that have performed at least one transaction (transferred money to another account) sorted in ascending order.

Note

Use LEFT or INNER join type to complete this task.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 2. Capítulo 7
toggle bottom row

Challenge: Query Optimization

Let's discover two tables: BankAccounts and one additional table named Transactions.

BankAccounts table

Transactions table

Assume we want to retrieve only the account numbers that have performed at least one transaction.

In this task, we have a query that is not optimized. Your task is to rewrite it in a more optimal way.

Here is a list of the main query rewriting techniques to enhance optimization:

  1. Explicitly Specify Columns: Instead of using the asterisk (*) wildcard, explicitly mention column names in queries for better performance, readability, and maintainability;
  2. Minimize Subqueries: Reduce the use of subqueries to optimize query performance. Consider alternatives like joins or derived tables to avoid complexity and overhead;
  3. Avoid Repeated IN Operators: Limit the use of the IN operator in queries to prevent performance impact. Instead, consider using JOIN or EXISTS clauses for more efficient execution plans;
  4. Organize Joins Logically: Start SQL joins with the main table and then join with related tables to optimize query organization and database engine optimization;
  5. Use Restrictive WHERE Conditions: Improve query performance by including restrictive conditions in the WHERE clause to filter rows and enhance execution speed;
  6. Refactor Code into Stored Procedures or Functions: Encapsulate repetitive code segments into stored procedures or user-defined functions for code reusability, modularity, and easier maintenance. These can reduce redundancy and optimize SQL queries.

Tarefa

Please rewrite the query more optimally. Pay attention to the fact that we need to get only account numbers that have performed at least one transaction (transferred money to another account) sorted in ascending order.

Note

Use LEFT or INNER join type to complete this task.

Tarefa

Please rewrite the query more optimally. Pay attention to the fact that we need to get only account numbers that have performed at least one transaction (transferred money to another account) sorted in ascending order.

Note

Use LEFT or INNER join type to complete this task.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Let's discover two tables: BankAccounts and one additional table named Transactions.

BankAccounts table

Transactions table

Assume we want to retrieve only the account numbers that have performed at least one transaction.

In this task, we have a query that is not optimized. Your task is to rewrite it in a more optimal way.

Here is a list of the main query rewriting techniques to enhance optimization:

  1. Explicitly Specify Columns: Instead of using the asterisk (*) wildcard, explicitly mention column names in queries for better performance, readability, and maintainability;
  2. Minimize Subqueries: Reduce the use of subqueries to optimize query performance. Consider alternatives like joins or derived tables to avoid complexity and overhead;
  3. Avoid Repeated IN Operators: Limit the use of the IN operator in queries to prevent performance impact. Instead, consider using JOIN or EXISTS clauses for more efficient execution plans;
  4. Organize Joins Logically: Start SQL joins with the main table and then join with related tables to optimize query organization and database engine optimization;
  5. Use Restrictive WHERE Conditions: Improve query performance by including restrictive conditions in the WHERE clause to filter rows and enhance execution speed;
  6. Refactor Code into Stored Procedures or Functions: Encapsulate repetitive code segments into stored procedures or user-defined functions for code reusability, modularity, and easier maintenance. These can reduce redundancy and optimize SQL queries.

Tarefa

Please rewrite the query more optimally. Pay attention to the fact that we need to get only account numbers that have performed at least one transaction (transferred money to another account) sorted in ascending order.

Note

Use LEFT or INNER join type to complete this task.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 2. Capítulo 7
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt