You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sql: store short_channel_id as integer for efficient indexing
Short channel IDs were stored as TEXT strings (e.g., "735095x480x1") in
SQLite, which prevented efficient use of indexes on SCID columns. Change
storage to INTEGER (the u64 encoding), using a custom "SCID" column type
so the result-reading code can detect these columns and format them back
as "NNNxNNNxNNN" strings for backward-compatible JSON output.
Add two new SQL functions:
- scid('NNNxNNNxNNN') -> integer: for efficient WHERE clause filtering
- fmt_scid(integer) -> 'NNNxNNNxNNN': for formatting in SQL expressions
Fixes#8941
Copy file name to clipboardExpand all lines: contrib/msggen/msggen/schema.json
+12-7Lines changed: 12 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -26381,7 +26381,8 @@
26381
26381
"INTEGER",
26382
26382
"BLOB",
26383
26383
"TEXT",
26384
-
"REAL"
26384
+
"REAL",
26385
+
"SCID"
26385
26386
],
26386
26387
"description": [
26387
26388
"The SQL type of the column."
@@ -26501,15 +26502,15 @@
26501
26502
},
26502
26503
{
26503
26504
"name": "short_channel_id",
26504
-
"type": "TEXT"
26505
+
"type": "SCID"
26505
26506
},
26506
26507
{
26507
26508
"name": "alias_local",
26508
-
"type": "TEXT"
26509
+
"type": "SCID"
26509
26510
},
26510
26511
{
26511
26512
"name": "alias_remote",
26512
-
"type": "TEXT"
26513
+
"type": "SCID"
26513
26514
},
26514
26515
{
26515
26516
"name": "opener",
@@ -34093,9 +34094,11 @@
34093
34094
" * JSON: string",
34094
34095
" * sqlite3: TEXT",
34095
34096
"",
34096
-
"* *short_channel_id*. A short-channel-id of form 1x2x3.",
34097
+
"* *short_channel_id*. A short-channel-id of form 1x2x3. Stored as an integer internally for efficient indexing.",
34097
34098
" * JSON: string",
34098
-
" * sqlite3: TEXT"
34099
+
" * sqlite3: SCID (INTEGER affinity)",
34100
+
"",
34101
+
"You can use the `scid()` function to convert a short_channel_id string to its integer representation for queries, e.g. `WHERE in_channel = scid('1x2x3')`. The `fmt_scid()` function converts back to string form."
34099
34102
],
34100
34103
"permitted_sqlite3_functions": [
34101
34104
"Writing to the database is not permitted, and limits are placed on various other query parameters.",
@@ -34124,7 +34127,9 @@
34124
34127
"* total",
34125
34128
"* unixepoch",
34126
34129
"* json_object",
34127
-
"* json_group_array"
34130
+
"* json_group_array",
34131
+
"* scid",
34132
+
"* fmt_scid"
34128
34133
],
34129
34134
"tables": [
34130
34135
"Note that tables which have a `created_index` field use that as the primary key (and `rowid` is an alias to this), otherwise an explicit `rowid` integer primary key is generated, whose value changes on each refresh. This field is used for related tables to refer to specific rows in their parent. (sqlite3 usually has this as an implicit column, but we make it explicit as the implicit version is not allowed to be used as a foreign key).",
Copy file name to clipboardExpand all lines: doc/schemas/sql-template.json
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -78,9 +78,11 @@
78
78
" * JSON: string",
79
79
" * sqlite3: TEXT",
80
80
"",
81
-
"* *short_channel_id*. A short-channel-id of form 1x2x3.",
81
+
"* *short_channel_id*. A short-channel-id of form 1x2x3. Stored as an integer internally for efficient indexing.",
82
82
" * JSON: string",
83
-
" * sqlite3: TEXT"
83
+
" * sqlite3: SCID (INTEGER affinity)",
84
+
"",
85
+
"You can use the `scid()` function to convert a short_channel_id string to its integer representation for queries, e.g. `WHERE in_channel = scid('1x2x3')`. The `fmt_scid()` function converts back to string form."
84
86
],
85
87
"permitted_sqlite3_functions": [
86
88
"Writing to the database is not permitted, and limits are placed on various other query parameters.",
@@ -109,7 +111,9 @@
109
111
"* total",
110
112
"* unixepoch",
111
113
"* json_object",
112
-
"* json_group_array"
114
+
"* json_group_array",
115
+
"* scid",
116
+
"* fmt_scid"
113
117
],
114
118
"tables": [
115
119
"Note that tables which have a `created_index` field use that as the primary key (and `rowid` is an alias to this), otherwise an explicit `rowid` integer primary key is generated, whose value changes on each refresh. This field is used for related tables to refer to specific rows in their parent. (sqlite3 usually has this as an implicit column, but we make it explicit as the implicit version is not allowed to be used as a foreign key).",
0 commit comments