

In Oracle, there are two ways to see the execution plan for a query:
#Datagrip sql how to#
Let’s take a look at how to view the execution plan in Oracle, SQL Server, MySQL, and PostgreSQL. The steps to see it, and what it looks like, is different in each database. So we know what an execution plan is, and why we need one. You can view the execution plan, and see all of this information, to help make a decision on how to improve your query. The reads and writes involved in the step.The exact details depend on which database you’re working on (which we’ll go into detail later), but generally, you’ll be able to see: The execution plan is the way to see this information. Just looking at the tables and columns and other clauses in the SQL statement is not enough to tell if the query will run efficiently. It’s because it’s a great way to see if there are any inefficient steps and areas to improve. Most articles, videos, and books about SQL performance and writing good SQL mention viewing the execution plan of a query as one of the first steps. The output is called an execution plan, so we’ll be using that term in this guide. Essentially, it’s an SQL command, or a label on a button. What is it, and how is it different to an execution plan?Īn execution plan is the sequence of steps that the database will take.Īn explain plan is a feature in many IDEs to display the execution plan.

You might have heard the term “explain plan” before. What’s the Difference Between an Execution Plan and an Explain Plan? The execution plan is the list of steps that the database takes to run that query.Īn execution plan is commonly shown for a SELECT query, but they can also be prepared for other SQL queries such as INSERT, UPDATE, and DELETE.

You specify the tables you want the data from, and the database works out the most efficient way to give you this data. With SQL, you specify the “what”, and the database figures out the “how”. In other programming languages, such as JavaScript, you specify how things are done, with variables and functions and loops. You’re specifying the “what”, and not the “how”. When you write an SQL query, you specify what you want to be done, such as the columns to see and the tables to get data from. An execution plan (or query plan) is the sequence of steps that the database plans to take to execute a query.
