This article is a mirror article of machine translation, please click here to jump to the original article.

View: 26469|Reply: 3

[Source] EF is cautious about random data

[Copy link]
Posted on 4/25/2019 5:01:42 PM | | | |
Today, the server suffered a CC attack, causing the website on IIS to hang, and the website was hung up again after restarting, check the website error log as follows:

System.Data.Entity.Core.EntityCommandExecutionException: 执行命令定义时出错。有关详细信息,请参阅内部异常。 ---> System.Data.SqlClient.SqlException: 执行超时已过期。完成操作之前已超时或服务器未响应。  ---> System.ComponentModel.Win32Exception: 等待的操作过时。


A large number of query timeout exceptions cause the website to hang, and the query timeout SQL statements all come from a method of taking random data, the code is as follows:

The code roughly means: 10 pieces of data are randomly selected from the database, as long as they do not duplicate the current ID.

What seems like a simple requirement has caused the server to hang up! The SQL statement generated by the above code is as follows:

The implementation plan is as follows:



If the database has 1 million pieces of data, wouldn't it take 999,999 pieces of data first, and then take 10 pieces of data from these 999,999 pieces of data?

Ask the big guy of the dba group and get the answer: "yesOh my God, that must be slow, and you need to call this sql statement many times.



At first I thought it was an EF problem,In fact, if you write directly in sql, there is no good solution

If so, please teach me!




Previous:The open-source project HtmlAgilityPack implements the C# web crawler
Next:2019 HCIA Learning Videos
Posted on 4/25/2019 5:07:00 PM |
learned
Posted on 4/26/2019 9:20:13 AM |
In the program, there are ten random numbers and then sql in this number is perfect
Posted on 4/26/2019 1:08:53 PM |
I learned ~~~~~~~~~~~~~~~~
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com