Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions store/postgres/src/relational/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,9 @@ impl TablePair {
loop {
let start = Instant::now();
let LastVid { last_vid, rows } = conn.transaction(|| {
// The query limits the number of rows we look at in each
// batch, rather than the number of matching rows to make
// the timing for each batch independent of how many rows we
// actually need to copy. This has the downside that it will
// force a sequential scan, but limiting by the number of
// matching rows runs the risk of a batch taking
// unpredictably long if there are only very few matches.
// Strictly speaking, the `vid >= $3` and `limit` clauses on
// the outer query are redundant.
sql_query(&format!(
"with cp as (insert into {dst}({column_list}) \
select {column_list} from ( \
select {column_list} from {src} \
where vid >= $3 \
order by vid \
limit $4) a \
select {column_list} from {src} \
where lower(block_range) <= $2 \
and coalesce(upper(block_range), 2147483647) > $1 \
and coalesce(upper(block_range), 2147483647) <= $2 \
Expand Down Expand Up @@ -166,15 +153,9 @@ impl TablePair {
loop {
let start = Instant::now();
let LastVid { rows, last_vid } = conn.transaction(|| {
// See the comment on the query in `copy_final_entities` for
// why this query is written this way
sql_query(&format!(
"with cp as (insert into {dst}({column_list}) \
select {column_list} from ( \
select {column_list} from {src} \
where vid >= $2 \
order by vid \
limit $3) a
select {column_list} from {src} \
where coalesce(upper(block_range), 2147483647) > $1 \
and block_range && int4range($1, null) \
and vid >= $2 \
Expand Down