search

Home  >  Q&A  >  body text

java - SQL Server 大量Update和Insert操作如何提升性能?

阿神阿神2766 days ago498

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 16:28:12

    1. 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之类的

    2. 在逻辑层解决这个问题
      服务启动的时候, 把所有的item_id => (pre_time, cur_time, value)

    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.🎜🎜 🎜

    reply
    0
  • 天蓬老师

    天蓬老师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

    reply
    0
  • Cancelreply