Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VOSpace INAF
vospace-rest
Commits
a64d0815
Commit
a64d0815
authored
Sep 14, 2021
by
Sonia Zorba
Browse files
Optimized some queries (tested with 10M+ nodes)
parent
adcba2fb
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
View file @
a64d0815
...
...
@@ -106,7 +106,7 @@ public class NodeDAO {
+
"c.type, c.async_trans, c.sticky, c.job_id IS NOT NULL AS busy_state, c.creator_id, c.group_read, c.group_write,\n"
+
"c.is_public, c.content_length, c.created_on, c.last_modified, c.accept_views, c.provide_views, c.quota, c.content_md5, c.target\n"
+
"FROM node n\n"
+
"JOIN node c ON c.pa
th ~ (n.path::varchar || ? || '*{1}')::lquery
OR c.path = n.path\n"
+
"JOIN node c ON c.pa
rent_path = n.path
OR c.path = n.path\n"
+
"WHERE n.node_id = id_from_vos_path(?)\n"
+
"ORDER BY vos_path"
;
...
...
@@ -116,7 +116,6 @@ public class NodeDAO {
ps
.
setString
(++
i
,
path
);
ps
.
setString
(++
i
,
path
);
ps
.
setString
(++
i
,
"/"
.
equals
(
path
)
?
""
:
"/"
);
ps
.
setString
(++
i
,
"/"
.
equals
(
path
)
?
""
:
"."
);
ps
.
setString
(++
i
,
path
);
return
ps
;
},
(
row
,
index
)
->
{
...
...
@@ -317,8 +316,8 @@ public class NodeDAO {
}
public
void
renameNode
(
Long
nodeId
,
String
name
)
{
String
sql
=
"UPDATE node SET name = ?
\n
, os_name = COALESCE(os_name, name)"
+
"WHERE
path ~ ('*.' || ?)::lquery
"
;
String
sql
=
"UPDATE node SET name = ?, os_name = COALESCE(os_name, name)
"
+
"WHERE
node_id = ?
"
;
jdbcTemplate
.
update
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
...
...
@@ -413,8 +412,10 @@ public class NodeDAO {
}
public
void
setBranchJobId
(
Long
rootNodeId
,
String
jobId
)
{
String
sql
=
"UPDATE node SET job_id = ?\n"
+
"WHERE path ~ ('*.' || ? || '.*')::lquery"
;
String
sql
=
"UPDATE node c SET job_id = ? "
+
"FROM node r "
+
"WHERE r.node_id = ? "
+
"AND r.path @> c.path"
;
jdbcTemplate
.
update
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment