select snapshot.id as snapshot_id, snapshot_branch.name as branch_name, content.sha1, walk.* from ( select snapshot.object_id as object_id from origin tablesample system (0.00001) inner join origin_visit on origin_visit.origin = origin.id inner join snapshot on origin_visit.snapshot_id = snapshot.object_id group by snapshot.object_id ) as snapshot inner join snapshot_branches on snapshot.object_id = snapshot_branches.snapshot_id inner join snapshot_branch on snapshot_branch.object_id = snapshot_branches.branch_id inner join revision on snapshot_branch.target = revision.id join lateral swh_directory_walk(revision.directory) walk on true inner join content on walk.target = content.sha1_git where true and snapshot_branch.target_type = 'revision' and snapshot_branch.name = 'HEAD' and walk.type = 'file';