diff --git a/internal/praefect/datastore/collector.go b/internal/praefect/datastore/collector.go
index 40390b47af3c967fc78f73f1145eae20e18f4c5b..c0184d17f6f7f7a9ab4ce48af5e4942cadc1f496 100644
--- a/internal/praefect/datastore/collector.go
+++ b/internal/praefect/datastore/collector.go
@@ -78,11 +78,6 @@ func (c *RepositoryStoreCollector) Collect(ch chan<- prometheus.Metric) {
 // they are either unhealthy or out of date.
 func (c *RepositoryStoreCollector) queryMetrics(ctx context.Context) (map[string]int, error) {
 	rows, err := c.db.QueryContext(ctx, `
-WITH valid_primaries AS MATERIALIZED (
-	SELECT virtual_storage, relative_path
-	FROM valid_primaries
-)
-
 SELECT virtual_storage, COUNT(*)
 FROM repositories
 WHERE NOT EXISTS (
diff --git a/internal/praefect/datastore/repository_store.go b/internal/praefect/datastore/repository_store.go
index 3d68ea7dea725746be8111b14f37f779304b2e50..556cc0108cdd618c787dfb840e1eef112761e4b1 100644
--- a/internal/praefect/datastore/repository_store.go
+++ b/internal/praefect/datastore/repository_store.go
@@ -651,10 +651,6 @@ func (rs *PostgresRepositoryStore) GetPartiallyAvailableRepositories(ctx context
 	//    than the assigned ones.
 	//
 	rows, err := rs.db.QueryContext(ctx, `
-WITH valid_primaries AS MATERIALIZED (
-	SELECT * FROM valid_primaries
-)
-
 SELECT
 	json_build_object (
 		'RelativePath', relative_path,