def METHOD_NAME(cursor, result_callback, min_date):
    # delete older machine snapshot commits
    start_t = time.time()
    cursor.execute(DELETE_MACHINE_SNAPSHOT_COMMIT_QUERY, [min_date])
    result_callback("machine_snapshot_commit", {"rowcount": cursor.rowcount,
                                                "duration": time.time() - start_t,
                                                "status": 0})
    # orphans
    for table, attr, links in ORPHANS:
        wheres = []
        for idx, (fk_attr, fk_table) in enumerate(links):
            # we use an alias for the fk_table to avoid collision with the table
            # inventory_certificate references inventory_certificate for example
            wheres.append(
                f"NOT EXISTS (SELECT 1 FROM {fk_table} fkt{idx} WHERE {table}.{attr} = fkt{idx}.{fk_attr})"
            )
        wheres = " AND ".join(wheres)
        query = f"DELETE FROM {table} WHERE {wheres}"
        # 3 attempts. Things could be added in the linked table while we are deleting.
        # TODO: better?
        for i in range(3):
            if i:
                print(f"Retry in {i}s…")
                time.sleep(i)
            orphan_start_t = time.time()
            try:
                cursor.execute(query)
            except IntegrityError:
                print(f"Could not purge table {table} because of an integrity error")
            else:
                result_callback(table, {"attempts": i + 1,
                                        "rowcount": cursor.rowcount,
                                        "duration": time.time() - orphan_start_t,
                                        "status": 0})
                break
        else:
            result_callback(table, {"attempts": i + 1,
                                    "status": 1})
    return time.time() - start_t