Home > Net >  C # a for loop speed too slow
C # a for loop speed too slow

Time:03-04

A for loop, loop values are in essentially a database query to verify whether the presence of
Can successfully circulation, once the cycle more value will be very slow, what's not to change authentication database under the premise of to speed up the

CodePudding user response:

Database constantly switch do?
Connection open only once, for query, check again after closing

Or use in statement one-time query out slowly filtering

CodePudding user response:

Don't frequent opening and closing the database connection

CodePudding user response:

With batch statements, don't check a, each loop check 100 times and check 1 time efficiency certainly is not the same

CodePudding user response:

Some unnecessary calculation and judgment to do with the code, reduce the number of querying the database, speed up naturally

CodePudding user response:

Directly to a stored procedure, you pass the minnum with maxnum parameters, the stored procedure to verify to return as a result, the SDR is useless, and you,, every times carried out two select statements,

CodePudding user response:

Database of switch is relatively time consuming, can consider multiple statements, or a stored procedure, once submitted

CodePudding user response:

1, the needed data found out before cycle () the premise of data scale is not large,
With 2, cycle found out the validation data sets,

This database query only once,
  •  Tags:  
  • C#
  • Related