Skip to content

Commit

Permalink
Revert "store: pass list of indexes when pruning a subgraph"
Browse files Browse the repository at this point in the history
This reverts commit cd6d04c.
  • Loading branch information
lutter committed Feb 11, 2025
1 parent cd6d04c commit a3f3da7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
16 changes: 4 additions & 12 deletions store/postgres/src/relational/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,16 +734,6 @@ pub struct IndexList {
pub(crate) indexes: HashMap<String, Vec<CreateIndex>>,
}

pub fn load_indexes_from_table(
conn: &mut PgConnection,
table: &Arc<Table>,
schema_name: &str,
) -> Result<Vec<CreateIndex>, StoreError> {
let table_name = table.name.as_str();
let indexes = catalog::indexes_for_table(conn, schema_name, table_name)?;
Ok(indexes.into_iter().map(CreateIndex::parse).collect())
}

impl IndexList {
pub fn load(
conn: &mut PgConnection,
Expand All @@ -756,8 +746,10 @@ impl IndexList {
let schema_name = site.namespace.clone();
let layout = store.layout(conn, site)?;
for (_, table) in &layout.tables {
let indexes = load_indexes_from_table(conn, table, schema_name.as_str())?;
list.indexes.insert(table.name.to_string(), indexes);
let table_name = table.name.as_str();
let indexes = catalog::indexes_for_table(conn, schema_name.as_str(), table_name)?;
let collect: Vec<CreateIndex> = indexes.into_iter().map(CreateIndex::parse).collect();
list.indexes.insert(table_name.to_string(), collect);
}
Ok(list)
}
Expand Down
15 changes: 3 additions & 12 deletions store/postgres/src/relational/prune.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, fmt::Write, sync::Arc, time::Instant};
use std::{fmt::Write, sync::Arc, time::Instant};

use diesel::{
connection::SimpleConnection,
Expand All @@ -24,10 +24,7 @@ use crate::{
relational::{Table, VID_COLUMN},
};

use super::{
index::{load_indexes_from_table, IndexList},
Catalog, Layout, Namespace,
};
use super::{Catalog, Layout, Namespace};

// Additions to `Table` that are useful for pruning
impl Table {
Expand Down Expand Up @@ -97,15 +94,9 @@ impl TablePair {
if catalog::table_exists(conn, dst_nsp.as_str(), &dst.name)? {
writeln!(query, "truncate table {};", dst.qualified_name)?;
} else {
let mut list = IndexList {
indexes: HashMap::new(),
};
let indexes = load_indexes_from_table(conn, &src, dst_nsp.as_str())?;
list.indexes.insert(src.name.to_string(), indexes);

// In case of pruning we don't do delayed creation of indexes,
// as the asumption is that there is not that much data inserted.
dst.as_ddl(schema, catalog, Some(&list), &mut query)?;
dst.as_ddl(schema, catalog, None, &mut query)?;
}
conn.batch_execute(&query)?;

Expand Down

0 comments on commit a3f3da7

Please sign in to comment.