Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL explain plan: what is Materialize?

I asked PostgreSQL to explain my query. Part of the explanation was:

table_name --> Materialize 

What does materialize do? I'm joining two tables, not views or anything like that.

like image 773
Claudiu Avatar asked Jun 12 '10 19:06

Claudiu


People also ask

What is materialize in SQL?

Materialize is an engine that parses SQL (joins, aggregations, transformations, computations) into dataflows and uses them to maintain results of SQL queries incrementally as new events arrive.

What does materialize mean database?

Materialize is a streaming database for real-time applications. It lets you ask complex questions about your data using SQL, and incrementally maintains the results of these SQL queries up-to-date as the underlying data changes.

What is materialize in programming?

Materialize is a UI component library created with CSS, JavaScript, and HTML. Materialize UI components help in constructing attractive, consistent, and functional web pages and web apps, while adhering to modern web design principles such as browser portability, device independence, and graceful degradation.

Does materialized view store data?

A materialized view is a pre-computed data set derived from a query specification (the SELECT in the view definition) and stored for later use. Because the data is pre-computed, querying a materialized view is faster than executing a query against the base table of the view.


2 Answers

A materialize node means the output of whatever is below it in the tree (which can be a scan, or a full set of joins or something like that) is materalized into memory before the upper node is executed. This is usually done when the outer node needs a source that it can re-scan for some reason or other.

So in your case, the planner is determining that the result of a scan on one of your tables will fit in memory, and it till make it possible to choose an upper join operation that requires rescans while still being cheaper.

like image 75
Magnus Hagander Avatar answered Sep 23 '22 23:09

Magnus Hagander


It means that it can't use any index (or similar method) to make the join efficient, so as a last resort is materializes the result from one of the tables to have a smaller set to work with when joining against the other table.

like image 31
Guffa Avatar answered Sep 21 '22 23:09

Guffa