Skip to content Skip to sidebar Skip to footer

In Postgresql What Does Hashed Subplan Mean?

I want to know how the optimizer rewrote the query and how to read the execution plan in PostgreSQL Here is the sample code. DROP TABLE ords; CREATE TABLE ords ( ORD_ID INT NOT NUL

Solution 1:

You have the misconception that the optimizer rewrites the SQL statement. That is not the case. Rewriting the query is the job of the query rewriter, which for example replaces views with their definition. The optimizer comes up with a sequence of execution steps to compute the result. It produces a plan, not an SQL statement.

The optimizer plans two alternatives: either execute subplan 1 for each row found, or execute subplan 2 once (note that it is independent of a), build a hash table from the result and probe that hash for each row found in a.

At execution time, PostgreSQL decides to use the latter strategy, that is why subplan 1 is never executed.

Post a Comment for "In Postgresql What Does Hashed Subplan Mean?"