Page MenuHomeSoftware Heritage

googlecode import: Clean up visit wrongly targetting empty snapshot
Closed, ResolvedPublic

Description

The first run created only empty snapshots.
This is wrong so those empty visits should be cleaned up.

Related Objects

Event Timeline

ardumont renamed this task from googlecode import: Clean up visit targetting wrongly an empty snapshot to googlecode import: Clean up visit wrongly targetting empty snapshot.
ardumont closed this task as Resolved.Feb 13 2018, 2:26 PM
softwareheritage=> select count(*) from origin_visit inner join origin on origin_visit.origin = origin.id where origin.type = 'hg';
 count
--------
 126678
(1 row)
softwareheritage=> select count(*) from origin o inner join origin_visit ov on o.id=ov.origin where type='hg' and url like '%googlecode%' and ov.snapshot_id = 16;  # empty snapshot
 count
--------
 126661
(1 row)

softwareheritage=> select count(*) from origin o inner join origin_visit ov on o.id=ov.origin where type='hg' and url like '%googlecode%' and ov.snapshot_id is null;  # nothing in unforeseen case
 count
-------
    17
(1 row)
softwareheritage=> begin;
BEGIN


softwareheritage=> explain delete from origin_visit where origin in (select id from origin where type='hg' and url like '%googlecode%');
                                             QUERY PLAN
-----------------------------------------------------------------------------------------------------
 Delete on origin_visit  (cost=1.26..84678.70 rows=24 width=12)
   ->  Nested Loop  (cost=1.26..84678.70 rows=24 width=12)
         ->  Index Scan using origin_type_url_idx on origin  (cost=0.69..84184.18 rows=9 width=14)
               Index Cond: (type = 'hg'::text)
               Filter: (url ~~ '%googlecode%'::text)
         ->  Index Scan using origin_visit_pkey on origin_visit  (cost=0.57..54.69 rows=26 width=14)
               Index Cond: (origin = origin.id)
(7 rows)

softwareheritage=> delete from origin_visit where origin in (select id from origin where type='hg' and url like '%googlecode%');
DELETE 126678

softwareheritage=> commit;
COMMIT