Changes between Initial Version and Version 1 of DatabaseCleanup


Ignore:
Timestamp:
Apr 9, 2015, 1:05:46 PM (9 years ago)
Author:
casties
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseCleanup

    v1 v1  
     1
     2== Database cleanup queries ==
     3
     4All entities with more than one CURRENT_VERSION:
     5{{{
     6select count(*) as cnt, id, node_type from openmind.node
     7where system_status = 'CURRENT_VERSION'
     8group by id
     9having cnt > 1
     10order by cnt desc;
     11}}}
     12
     13All relations without source or target:
     14{{{
     15select * from openmind.node where node_type = 'RELATION' and (source_id is null or target_id is null);
     16}}}
     17
     18All relations with target pointing at nonexistent entity:
     19{{{
     20select * from openmind.node rel
     21left outer join openmind.node ent
     22on rel.target_id = ent.id
     23where
     24rel.node_type = 'RELATION'
     25and ent.id is null;
     26}}}
     27
     28All current relations pointing at non-current target entities:
     29{{{
     30select * from openmind.node rel, openmind.node ent
     31where
     32rel.target_id = ent.id
     33and rel.target_modif = ent.modification_time
     34and rel.system_status = 'CURRENT_VERSION'
     35and ent.system_status != 'CURRENT_VERSION';
     36}}}