Write the logic directly to SqlServer. SqlServer supports complex statements, that is, item_id, this_value, time_now can be used as parameters of a stored procedure. Write select if update insert and the like of item_id, this_value, time_now可以当作一个存储过程的参数. 里面写select if update insert之类的
Solve this problem at the logic layer🎜 When the service starts, load all item_id => (pre_time, cur_time, value) and then cache them. When processing new messages , you will know whether to update or insert. In the end, you only need to process one SQL statement. It is easy to process 1000+ SQL statements per second, just use a few Connections.🎜🎜
🎜
Write the logic directly to SqlServer.
SqlServer supports complex statements, that is,
item_id, this_value, time_now
can be used as parameters of a stored procedure. Write select if update insert and the like ofitem_id, this_value, time_now
可以当作一个存储过程的参数. 里面写select if update insert之类的在逻辑层解决这个问题
服务启动的时候, 把所有的
item_id => (pre_time, cur_time, value)
item_id => (pre_time, cur_time, value)
and then cache them. When processing new messages , you will know whether to update or insert. In the end, you only need to process one SQL statement. It is easy to process 1000+ SQL statements per second, just use a few Connections.🎜🎜 🎜Batch processing, don’t access the database every time there is a piece of data, perform a database access operation every 100 pieces