Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
commoncrawl_graph
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Stephen D
commoncrawl_graph
Commits
fcbcd27a
Commit
fcbcd27a
authored
3 months ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
improve edge insertion speed, I hope
parent
cbf2f7c4
Branches
import_all_versions
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bin/import.rs
+21
-1
21 additions, 1 deletion
src/bin/import.rs
with
21 additions
and
1 deletion
src/bin/import.rs
+
21
−
1
View file @
fcbcd27a
...
@@ -238,7 +238,27 @@ async fn get_edges(
...
@@ -238,7 +238,27 @@ async fn get_edges(
})
})
.unzip
();
.unzip
();
query!
(
"INSERT INTO edges(from_id, to_id) SELECT UNNEST($1::INT[]), UNNEST($2::INT[]) ON CONFLICT DO NOTHING"
,
&
from_ids
,
&
to_ids
)
.execute
(
&
p
)
.await
?
;
query!
(
r#"
WITH unique_edges AS (
SELECT UNNEST($1::INT[]) AS from_id, UNNEST($2::INT[]) AS to_id
)
INSERT INTO edges(from_id, to_id)
SELECT ue.from_id, ue.to_id
FROM unique_edges ue
WHERE NOT EXISTS (
SELECT 1
FROM edges e
WHERE e.from_id = ue.from_id
AND e.to_id = ue.to_id
)
ON CONFLICT DO NOTHING
"#
,
&
from_ids
,
&
to_ids
)
.execute
(
&
p
)
.await
?
;
statsd
.count
(
"edges.inserts"
,
from_ids
.len
()
as
f64
,
&
None
);
statsd
.count
(
"edges.inserts"
,
from_ids
.len
()
as
f64
,
&
None
);
...
...
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