diff --git a/swh/dataset/cli.py b/swh/dataset/cli.py
index 304e7a496673701a72c0fd7b0fcd732c2427d8ed..bc9f3a7d1159db6735a5e53a41168994aa90aee5 100644
--- a/swh/dataset/cli.py
+++ b/swh/dataset/cli.py
@@ -124,6 +124,11 @@ def export_graph(
                 option_name="formats", message=f"{f} is not an available format."
             )
 
+    # Enforce order (from origin to contents) to reduce number of holes in the graph.
+    object_types = [
+        obj_type for obj_type in MAIN_TABLES.keys() if obj_type in object_types
+    ]
+
     def importcls(clspath):
         mod, cls = clspath.split(":")
         m = import_module(mod)