graph/db+sqldb: queries and logic for batch fetching node data

In this commit, we add the queries that will be needed to batch-fetch
the data of a set of nodes. The logic for using these new queries is
also added but not used yet.
This commit is contained in:
Elle Mouton
2025-07-29 07:45:49 +02:00
parent 4389067989
commit 0dc0d320f8
4 changed files with 301 additions and 0 deletions

View File

@@ -114,6 +114,12 @@ FROM graph_nodes n
WHERE n.pub_key = $1
AND n.version = $2;
-- name: GetNodeFeaturesBatch :many
SELECT node_id, feature_bit
FROM graph_node_features
WHERE node_id IN (sqlc.slice('ids')/*SLICE:ids*/)
ORDER BY node_id, feature_bit;
-- name: DeleteNodeFeature :exec
DELETE FROM graph_node_features
WHERE node_id = $1
@@ -140,6 +146,12 @@ FROM graph_node_addresses
WHERE node_id = $1
ORDER BY type ASC, position ASC;
-- name: GetNodeAddressesBatch :many
SELECT node_id, type, position, address
FROM graph_node_addresses
WHERE node_id IN (sqlc.slice('ids')/*SLICE:ids*/)
ORDER BY node_id, type, position;
-- name: GetNodesByLastUpdateRange :many
SELECT *
FROM graph_nodes
@@ -170,6 +182,12 @@ SELECT *
FROM graph_node_extra_types
WHERE node_id = $1;
-- name: GetNodeExtraTypesBatch :many
SELECT node_id, type, value
FROM graph_node_extra_types
WHERE node_id IN (sqlc.slice('ids')/*SLICE:ids*/)
ORDER BY node_id, type;
-- name: DeleteExtraNodeType :exec
DELETE FROM graph_node_extra_types
WHERE node_id = $1