]> Git — Sourcephile - gargantext.git/blob - devops/postgres/tools/removeUnusedDocuments.sql
[FIX] Order 2
[gargantext.git] / devops / postgres / tools / removeUnusedDocuments.sql
1
2 WITH repeated AS
3 ( select nn.node2_id AS id, count(*) AS c
4 FROM nodes_nodes nn
5 GROUP BY nn.node2_id
6 )
7
8 DELETE FROM nodes n
9 USING repeated r
10 WHERE
11 n.id = r.id
12 AND r.c <= 1
13 AND n.typename = 4
14 ;
15