SqlCommand.Cancel() causes a performance boost?

前端 未结 4 782
感情败类
感情败类 2021-02-08 02:21

I have seen this show up several places in code, never with an explanation, just a cryptic comment above it (Declaration and execution included for an idea of context. It\'s jus

4条回答
  •  囚心锁ツ
    2021-02-08 02:48

    Our Tech team at Cinchcast did some benchmarking, and we have found that adding the cmd.Cancel() actually slows it down.

    We have a DALC call that gets a list of episodes for a host. We ran it 1000 times and got the average response time to return 10 episodes.

    So with returning 10 shows Average With Cancel: 0.069s Average Without Cancel : 0.026s

    Pretty significantly slower when running with returning 10 episode.

    So, I tried again with returning 100 episodes to see if a larger result set makes a difference.

    So with returning 100 shows on each call Average With Cancel: 0.132s Average Without Cancel : 0.122s

    So this time the difference in time was much less. It is still faster though without using the Cancel for our usual use cases.

提交回复
热议问题