Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要检查特定数据是否存在于数据库中的 table1 中或不在 for 循环中。如果存在,则不执行任何操作并且 for 循环继续,否则我应该将数据添加到 table1。
因此,在每次迭代中,我都会查看数据库。我相信这很耗时。
有没有做这些任务的最佳实践?
有多少数据,什么样的 SQL 实现可以在这里产生很大的不同......
例如,对于 1000 万行数据,进行 1000 万次(可能记录的)操作,每行一个操作将花费几个数量级的 a 比例如: