PostgreSQL CTE by id string is very cheap, but by id from query is very expensive
I use the id directly in the query, it has a low cost: -- Query 1. -- Nested Loop Semi Join (cost=2.27..280.78 rows=1 width=129) EXPLAIN SELECT * FROM view_companies_extra WHERE company_id iN ( SELECT id FROM companies WHERE id =…