mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 10:13:24 +02:00
graph/db+sqldb: improve efficiency of node migration
There is no need to use the "collect-then-update" pattern for node insertion during the SQL migration since if we do have any previously persisted data for the node and happen to re-run the insertion for that node, the data will be exactly the same. So we can make use of "On conflict, no nothing" here too.
This commit is contained in:
@@ -105,7 +105,9 @@ INSERT INTO graph_node_features (
|
||||
node_id, feature_bit
|
||||
) VALUES (
|
||||
$1, $2
|
||||
);
|
||||
) ON CONFLICT (node_id, feature_bit)
|
||||
-- Do nothing if the feature already exists for the node.
|
||||
DO NOTHING;
|
||||
|
||||
-- name: GetNodeFeatures :many
|
||||
SELECT *
|
||||
@@ -135,7 +137,7 @@ WHERE node_id = $1
|
||||
───────────────────────────────────<E29480><E29480>─────────
|
||||
*/
|
||||
|
||||
-- name: InsertNodeAddress :exec
|
||||
-- name: UpsertNodeAddress :exec
|
||||
INSERT INTO graph_node_addresses (
|
||||
node_id,
|
||||
type,
|
||||
@@ -143,7 +145,8 @@ INSERT INTO graph_node_addresses (
|
||||
position
|
||||
) VALUES (
|
||||
$1, $2, $3, $4
|
||||
);
|
||||
) ON CONFLICT (node_id, type, position)
|
||||
DO UPDATE SET address = EXCLUDED.address;
|
||||
|
||||
-- name: GetNodeAddresses :many
|
||||
SELECT type, address
|
||||
|
Reference in New Issue
Block a user