0

I have a table tbl_a with 200 k records. I wrote a query to bring sum of id (int) column. Now execution plans shows 2 workers launched and below that parallel sequential scan on tbl_a is shown 3 times; with processing 66667 records each time(200k/3=66667). Now my question is since there were two workers so should there not be only two times table seq scan and each time with record 100k (200k/3). I am attaching the image which lists the table detail, query and query execution plan for better understanding. enter image description here

Can someone tell me why with 2 workers there are 3 loops , each processing 6667 records out of total 200k records?

1
  • Please edit your question and add the execution plan as formatted text (the screen shot is barely readable) and make sure you prevent the indention of the plan. Copy the text from the console then paste it into your question and put ``` on the line before the plan and on a line after the plan. Apr 16, 2020 at 8:32

1 Answer 1

2

The two worker processes are additional to the session backend process, which is the “parallel leader”, so there are three processes working on the scan.

1
  • Thanks a lot @Laurenz Albe. it was very helpful. Laurenz I was doing streaming replication and was getting errors on pg_hba.conf. Could you please look and help on question dba.stackexchange.com/questions/265853/…. It would really help. Apr 26, 2020 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.