Question

I have question about PostgreSQL join. Does PostgreSQL create temporary table for JOINed tables or it makes everything
without any temporary tables?

The reason of my question is: When I make SELECT request with many JOINs, I see IO spike in write operations. What can be the reason of this issue?

Thanks a lot.

Was it helpful?

Solution

PostgreSQL will temporarily spill result-sets to disk if they get large enough. Unless you have a database smaller than your RAM it doesn't have much choice.

However, you can also see unexpected writes if this is the first time you have read in data pages since they were created. There are "hint bits" set on each page to optimise visibility checks. These get set when vacuuming etc. or when a page is accessed. If you do a large import followed by a table scan you can get a lot of unexpected IO as all the hint bits get set and written out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top