0

Hello I'm playing around with postgres as a search engine by using GIN indexes with trigram module and partitioned table and I'm trying to parallelize the query but no matter what I set the query is always sequential any ideas are welcome. Check out the image for more info. Here is an query (test_trgm_x those are partitions which each holds around 550k rows)

SELECT * FROM test_trgm_1 WHERE n = 1 AND t ~ '(ulpa)'
UNION ALL
SELECT * FROM test_trgm_2 WHERE n = 2 AND t ~ '(piente)';

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

The default setting of parallel_tuple_cost is quite high. This discourages use of parallel query in cases like yours, where nearly every row found in the parallel worker needs to be shoved up to the leader. If you set parallel_tuple_cost=0, it will really encourage use of parallel query (even when it doesn't make sense to use it).

jjanes
  • 37,812
  • 5
  • 27
  • 34
  • I've set those variables (parallel_tuple_cost parallel_setup_cost) to 0 and still the query is executed seqentially . I'm starting to think that this might be just an limitation of partitioned tables ;( – Kamil Szulc Nov 07 '21 at 12:15
  • works for me. Do you ever get *any* parallel query execution? I'd show you on db-fiddle, but it doesn't support pg_trgm. – jjanes Nov 07 '21 at 15:20