Restore: Why is loading directories for restore so impossibly slow?

I’m still looking for SQL profiling times. Based mostly on name and SQL, I’m guessing the code is here:

and even with my tiny folder expansion logged earlier, this was the slowest SQL. Let me pretty-print that:

SELECT "C"."Path"
	,"D"."Length"
	,"C"."FilesetID"
FROM (
	SELECT "A"."Path"
		,"B"."FilesetID"
	FROM "Filenames-19C57E44B990C0428B3C69351597D57A" A
		,(
			SELECT "FilesetID"
				,"Timestamp"
			FROM "Filesets-10AA35FC3949D041B20F0B443D64DA0F"
			ORDER BY "Timestamp" DESC
			) B
	ORDER BY "A"."Path" ASC
		,"B"."Timestamp" DESC
	) C
LEFT OUTER JOIN (
	SELECT "Length"
		,"FilesetEntry"."FilesetID"
		,"File"."Path"
	FROM "Blockset"
		,"FilesetEntry"
		,"File"
	WHERE "File"."BlocksetID" = "Blockset"."ID"
		AND "FilesetEntry"."FileID" = "File"."ID"
		AND FilesetEntry."FilesetID" IN (
			SELECT DISTINCT "FilesetID"
			FROM "Filesets-10AA35FC3949D041B20F0B443D64DA0F"
			)
	) D ON "C"."FilesetID" = "D"."FilesetID"
	AND "C"."Path" = "D"."Path"

I think that query gets assembled in code below. I traced some but not all. Seeing “cartesian” worries me.

Documentation for the local database format. Any SQL experts out there who might have any opinions?