MySQL Forums
Forum List  »  Connector/C++

How to fast fill table
Posted by: Andrzej Borucki
Date: January 20, 2017 05:23AM

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?

Options: ReplyQuote


Subject
Views
Written By
Posted
How to fast fill table
1262
January 20, 2017 05:23AM
532
January 20, 2017 09:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.