diff --git a/swh/storage/backfill.py b/swh/storage/backfill.py --- a/swh/storage/backfill.py +++ b/swh/storage/backfill.py @@ -1,4 +1,4 @@ -# Copyright (C) 2017-2020 The Software Heritage developers +# Copyright (C) 2017-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -174,6 +174,11 @@ ], } +EXTRA_WHERE = { + # hack to force the right index usage on table extid + "extid": "target_type in ('revision', 'release', 'content', 'directory')" +} + def directory_converter(db: BaseDb, directory_d: Dict[str, Any]) -> Directory: """Convert directory from the flat representation to swh model @@ -461,6 +466,7 @@ columns = COLUMNS.get(obj_type) join_specs = JOINS.get(obj_type, []) join_clause = "\n".join("left join %s" % clause for clause in join_specs) + additional_where = EXTRA_WHERE.get(obj_type) where = [] where_args = [] @@ -471,6 +477,9 @@ where.append("%(keys)s < %%s") where_args.append(end) + if additional_where: + where.append(additional_where) + where_clause = "" if where: where_clause = ("where " + " and ".join(where)) % {