I am updating a row in MySQL database using UPDATE keyword (in an express server using mysql2). If the data I am using to update and the data in the row are same then it is taking time as usual. But if I update the table with different data then it takes longer time. There is my code below.
public update = async (
obj: TUpCred,
): Promise<ResultSetHeader> => {
const sql = 'UPDATE ?? SET ? WHERE ?';
const values = [obj.table, obj.data, obj.where];
const [data] = (await this.connection.query({
sql,
values,
})) as TResultSetHeader;
return data;
};
Then this query takes so long time. Usually it is taking 4 - 6 seconds but sometimes it even takes 10 to 15 seconds to update. The same happens with INSERT query. But other queries like SELECT is taking normal time to execute.