I have table of flags of bitcoin blocks - if the are confirmed (stage 0,1,2)
Initially I must "Insert..Ignore" 450'000 rows of (key,0)
At start table can several records
567, 1
753, 2
where 567 and 753 are keys
I must do:
0,0
1,0
2,0
3,0
....
566, 0
567, 1
568, 0
....
753, 2
...
449999, 0
I try: (MySqlDB my class)
MySqlDB db(user, password);
for (int i = start; i < start + count; i++)
{
db.execute("insert ignore blocks_confirmed (block_height, mysql) values ("+to_string(i)+", 0)");
}
but is very slow about 30 minutes
I better way? I ask and get:
SELECT * FROM x;
test=> WITH RECURSIVE x AS
(
SELECT 1 AS a, 0 AS b, 0 AS c
UNION ALL
SELECT 1+a, b, c FROM x WHERE a<100000
)
SELECT * FROM x;
But how to implement in code with C++ connector?
Initially I must "Insert..Ignore" 450'000 rows of (key,0)
At start table can several records
567, 1
753, 2
where 567 and 753 are keys
I must do:
0,0
1,0
2,0
3,0
....
566, 0
567, 1
568, 0
....
753, 2
...
449999, 0
I try: (MySqlDB my class)
MySqlDB db(user, password);
for (int i = start; i < start + count; i++)
{
db.execute("insert ignore blocks_confirmed (block_height, mysql) values ("+to_string(i)+", 0)");
}
but is very slow about 30 minutes
I better way? I ask and get:
SELECT * FROM x;
test=> WITH RECURSIVE x AS
(
SELECT 1 AS a, 0 AS b, 0 AS c
UNION ALL
SELECT 1+a, b, c FROM x WHERE a<100000
)
SELECT * FROM x;
But how to implement in code with C++ connector?