I am reading large Json file, and I wanna to map these objects in the file and insert them in the db
Json structure
{
"A": [
{
"key1": "value1",
"key2": "value2",
"B": [
{
"id": "34f852c8-fc51-47aa-ba7f-dd659a4bff3f",
"C": [
{
"c1": "819685-002",
}
]
}
]
},
{
"key1": "value1",
"key2": "value2",
"B": [
{
"id": "34f852c8-fc51-47aa-ba7f-dd659a4bff3f",
"C": [
{
"c1": "819685-002",
}
]
}
]
}
]
}
The file include multiple blocks of A
So i need to loop three nested loops
For (A){
for (B){
FOR (C) {
// CREATE THE AN OBJECT
}
}
}
// Then after the loop insert all objects once
db.bulk(//List of object created);
The issue it takes 3 minutes to insert 2557 record?
Any enhancement can be done to enhance the looping procedure ?