Question: npgsql how to improve performance?
Answer: Extract the query from the codebase.
Replay the query with an explain plan. EXPLAIN ANALYZE SELECT * FROM test; Hash Anti Join (cost=57.26.. 96.69 rows=53 width=31) (actual time=0.702.. ... 
Optimize the query. In our case, we only had a few changes to apply for a significant impact: