PHP中文网2017-04-17 16:28:12
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之类的
在逻辑层解决这个问题
服务启动的时候, 把所有的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.🎜🎜
🎜天蓬老师2017-04-17 16:28:12
Batch processing, don’t access the database every time there is a piece of data, perform a database access operation every 100 pieces