

I have highlighted only these two parameters, but you should also check the other ones. VERBOSE parameter will help to figure this out. This is very useful if you are working with a large query and having a hard time mapping the execution plan step and specific part of query. VERBOSE - this parameter gives some extra information about each step of execution plan. This gives us several benefits, such as being able to see the exact timing.

It also has several useful parameters: all of them are useful and can be seen in the doc, but the most notorious are:ĪNALYZE - this parameter not only builds query execution plan, but also runs the actual query. By monitoring cost increase, it is possible to detect a bottleneck in the query. When adding EXPLAIN statement to the query, by default it shows how RDBMS will interpret and execute the query, outputting step-by-step actions and their cost in abstract units. It can be used both in the basic psql shell and in more advanced environments. PostgreSQL comes with a native tool for profiling - EXPLAIN statement.
POSTGRES QUERY PLAN SOFTWARE
Despite having a foreign key, it is highly unlikely that there will be more than two or three deliveries for one order.Īlso, don’t forget about the software engineering rule of thumb - “profile before you optimize“.

For example, in your “Online Shop“ data model there may be a “Delivery“ entity with a foreign key to an “Order“ entity. Also, make sure that the business domain even allows a large amount of data to be created. So, before diving into the optimization routine, please make sure that the queried data will really come in a large amount. Before you optimizeĪ considerable amount of time can be spent optimizing SQL query, but it may not be needed: for example, if the predicted amount of data is not that high. The majority of tips should be applicable to any relational database management system, but the terminology and exact namings will be taken from PostgreSQL. Here are some tips on how you can make your SELECT queries better. For a large number of people who make use of SQL, learning to apply it efficiently takes lots of trials and errors. SQL is a fairly complicated language with a steep learning curve.
