You have a document of type A with categories from parent and you want to show document of type B with matching categories.
You can use repeater with a custom query, create a query something like:
select DocumentName, DocumentURLPath, CategoryID, * from View_Type_B_Joined vw join cms_documentCategory dc on vw.DocumentID = dc.documentid
where ##WHERE## and published = 1
And then in WHERE property of web part you put macro CategoryID in ({% String.Join(",",CurrentDocument.Parent.Categories.IDs)) |(identity)GlobalAdministrator%})
It is much faster, no DB call. Make sure your check 'Search on each page load' property