I have a POST API which accepts JSON in following format and inserts data in 5 tables.
But since I have to write 5 different queries to insert data, it takes longer time for API to give the response back.
{
"table1": [
{
"field1": "value1",
"field2": "value2",
"field3": "value3"
},
{
"field4": "value4",
"field5": "value5"
}
],
"table2": [
{
"field1": "value1",
"field2": "value2",
"field3": "value3"
}
],
"table3": [
{
"field1": "value1",
"field2": "value2",
"field3": "value3",
"field4": "value4"
},
{
"field5": "value5"
}
],
"table4": [
{
"field1": "value1",
"field2": "value2",
"field3": "value3",
"field4": "value4",
"field5": "value5"
}
]
}
I wanted to know if theres any tool or technique available out there by which I can execute the flow as following,
- Entire JSON would be inserted in a single table
- As soon as the it is inserted server will free the front end by giving the response.
- Once the client is given the response and is freed, then server will one by one insert the data in respective table.
such a flow will, make the API faster. Thank you for your suggestions.