Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-rest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
a64d0815
Commit
a64d0815
authored
3 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Optimized some queries (tested with 10M+ nodes)
parent
adcba2fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+12
-11
12 additions, 11 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
with
12 additions
and
11 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+
12
−
11
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
)
->
{
...
...
@@ -174,7 +173,7 @@ public class NodeDAO {
boolean
isLinkNode
=
newNode
instanceof
LinkNode
;
// If is link ignore recursive: LinkNodes are supposed to be childless
if
(
recursive
&&
!
isLinkNode
)
{
if
(
recursive
&&
!
isLinkNode
)
{
updatePermissionsRecursively
(
newNode
,
vosPath
);
}
else
{
jdbcTemplate
.
update
(
conn
->
{
...
...
@@ -185,7 +184,7 @@ public class NodeDAO {
if
(
isLinkNode
)
{
sql
+=
", target = ?\n"
;
}
sql
+=
"WHERE node_id = id_from_vos_path(?)\n"
;
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
...
...
@@ -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
);
...
...
@@ -345,7 +344,7 @@ public class NodeDAO {
return
ps
;
});
}
public
void
copyBranch
(
String
sourceVosPath
,
String
destVosPath
)
{
String
destVosParentPath
=
NodeUtils
.
getParentPath
(
destVosPath
);
...
...
@@ -392,14 +391,14 @@ public class NodeDAO {
+
"copied_nodes_paths AS ("
+
cteCopiedNodesPaths
+
")\n"
+
parentSelect
;
jdbcTemplate
.
update
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
destVosParentPath
);
ps
.
setString
(
2
,
destName
);
ps
.
setString
(
3
,
sourceVosPath
);
return
ps
;
});
});
}
public
boolean
isBranchBusy
(
long
parentNodeId
)
{
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment