Commit 6f8ff1c
committed
plugins/sql: add payment_hash index to channelmoves table.
This significantly speeds up the query which bookkeeper often does:
"SELECT created_index"
" FROM channelmoves"
" WHERE payment_hash = X'%s'"
" AND credit_msat = %"PRIu64
" AND created_index <= %"PRIu64,
On large databases this scan is expensive, and a payment_hash index
cuts it down a great deal. It does take longer to load the channelmoves
in the first place though (about 3x).
Before:
$ while sleep 10; do wc -l /tmp/bkpr-progress; done
169505 /tmp/bkpr-progress
196010 /tmp/bkpr-progress
219370 /tmp/bkpr-progress
235671 /tmp/bkpr-progress
244242 /tmp/bkpr-progress
255362 /tmp/bkpr-progress
265636 /tmp/bkpr-progress
276966 /tmp/bkpr-progress
284451 /tmp/bkpr-progress
288836 /tmp/bkpr-progress
296578 /tmp/bkpr-progress
304571 /tmp/bkpr-progress
After:
$ while sleep 10; do wc -l /tmp/bkpr-progress; done
161421 /tmp/bkpr-progress
238273 /tmp/bkpr-progress
281185 /tmp/bkpr-progress
305787 /tmp/bkpr-progress
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>1 parent d84850c commit 6f8ff1c
1 file changed
Lines changed: 14 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
200 | 204 | | |
201 | 205 | | |
202 | 206 | | |
| |||
1757 | 1761 | | |
1758 | 1762 | | |
1759 | 1763 | | |
1760 | | - | |
1761 | | - | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
1762 | 1768 | | |
1763 | 1769 | | |
1764 | | - | |
1765 | | - | |
1766 | | - | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
1767 | 1773 | | |
1768 | | - | |
1769 | | - | |
| 1774 | + | |
| 1775 | + | |
1770 | 1776 | | |
1771 | 1777 | | |
1772 | 1778 | | |
1773 | | - | |
| 1779 | + | |
1774 | 1780 | | |
1775 | 1781 | | |
1776 | 1782 | | |
| |||
0 commit comments