Skip to content

Conversation

@joshua-spacetime
Copy link
Collaborator

@joshua-spacetime joshua-spacetime commented Nov 6, 2025

Description of Changes

Materialize views if necessary for sql queries. Also update the subscriber count and last_called timestamp in st_view_sub.

API and ABI breaking changes

None

Expected complexity level and risk

1

Testing

TODO

Base automatically changed from joshua/drop-views-on-disconnect to master November 6, 2025 08:52
@joshua-spacetime joshua-spacetime force-pushed the joshua/update-st-view-sub-on-query branch 3 times, most recently from 0e43a96 to 8168623 Compare November 6, 2025 23:20
@joshua-spacetime joshua-spacetime changed the title Update last_called timestamp in st_view_sub for sql queries Materialize views for sql http calls Nov 6, 2025
@joshua-spacetime joshua-spacetime force-pushed the joshua/update-st-view-sub-on-query branch 2 times, most recently from 657d86b to 3c5530b Compare November 7, 2025 00:43
@joshua-spacetime joshua-spacetime force-pushed the joshua/update-st-view-sub-on-query branch from 3c5530b to eadfc38 Compare November 7, 2025 00:49
use spacetimedb_schema::schema::{Schema, TableSchema};
use spacetimedb_vm::relation::RelValue;
use std::collections::VecDeque;
use std::collections::{HashSet, VecDeque};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't use HashSet from libstd.

@@ -1,10 +1,28 @@
use std::sync::Arc;
use std::{collections::HashSet, sync::Arc};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines +257 to +274
self.visit(&mut |plan| match plan {
Self::TableScan(scan, _) => {
if let Some(info) = &scan.schema.view_info {
views.insert(info.view_id);
}
}
Self::IxScan(scan, _) => {
if let Some(info) = &scan.schema.view_info {
views.insert(info.view_id);
}
}
Self::IxJoin(join, _) => {
if let Some(info) = &join.rhs.view_info {
views.insert(info.view_id);
}
}
_ => {}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.visit(&mut |plan| match plan {
Self::TableScan(scan, _) => {
if let Some(info) = &scan.schema.view_info {
views.insert(info.view_id);
}
}
Self::IxScan(scan, _) => {
if let Some(info) = &scan.schema.view_info {
views.insert(info.view_id);
}
}
Self::IxJoin(join, _) => {
if let Some(info) = &join.rhs.view_info {
views.insert(info.view_id);
}
}
_ => {}
});
self.visit(&mut |plan| {
let view_info = match plan {
Self::TableScan(scan, _) => &scan.schema.view_info,
Self::IxScan(scan, _) => &scan.schema.view_info,
Self::IxJoin(join, _) => &join.rhs.view_info,
_ => return,
};
if let Some(info) = view_info {
views.insert(info.view_id);
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants