To address this, I tuned some of Postgresql parameters using https://pgtune.leopard.in.ua/#/
I ran the following SQL code to create indices to speed up the operation:
CREATE INDEX concept_id ON vocab.concept(concept_id);
CREATE INDEX descendant_concept_id ON vocab.concept_ancestor(descendant_concept_id);
I then ran each piece of the query separately, which all ran in < 5 minutes each and worked on joining them together piece by piece. Interestingly, the select command with everything now runs in 5:51 and full command executes in 1:18 minutes with the insert… odd. Recommend adding the vocabulary index’s to the DDL script.