Home > database >  The same stored procedure, the same data, the first and the second has a performance difference
The same stored procedure, the same data, the first and the second has a performance difference

Time:10-25

Write A stored procedure, the incoming parameter is the date, the role is to do the some data statistics, and insert into A table, and update A table A few fields, execution method such as the select p_aaa (20200214); P_aaa (20200215); The select p_aaa (20200216); P_aaa (20200217);

The first time I perform the select p_aaa (20200214); It only took 4 seconds,
The second performs the select p_aaa (20200215); Waiting for 3 minutes before the results. Look through the top, the CPU run 99%, look through the vmstat, no IO wait.
A judgment run 100% CPU is not indexed, but I to find the problem, I select p_aaa (20200214), and select p_aaa (20200215) is the same data processing, the only difference will add a row data.
The most magical is that I have modified the p_aaa stored procedure, just add a space, save the changes.
To execute the select p_aaa (20200215), is also the only took 4 seconds,
But I'll execute the select p_aaa (20200216), sometimes is to perform a select p_aaa (20200217), and stuck, such as the results haven't been out for a long time. I really don't understand.

That is to say, you restart the db or you modify the stored procedure (even if just add a space), also can make p_aaa run 1 to 2 times, then got stuck.
  • Related