none
Threaded Sql Commands in Windows Service RRS feed

  • Question

  • Hi,

    I have a long SQL process which I need to run in Windows Service. I have created the windows service application and did a test and all works find but I want to know what's the best way to make the sql command  threaded to get the best performance?

    Thanks,

    Jassim

    Wednesday, January 13, 2016 1:56 PM

Answers

  • Can you describe what you want to do? Also, what is your overall goal?

    As this is a .NET forum:

    A single SQL command "cannot be threaded to get the best performance". Cause a single SQL command needs to be started, then you'll need to wait for it to be finished. Threading does not help in this case.

    When you have multiple SQL commands, then the overall time span from starting the first command till the last is finished can be reduced, when each command is executed in its own thread. But as it is a Windows service, your commands should already run in its own thread.

    So I don't see here any potential for performace optimization.

    When talking about SQL: What is "a long SQL process"? SQL optimization has a lot of potential, but this has nothing to do with threads in regards to .NET.

    Wednesday, January 13, 2016 2:20 PM
  • Why reinventing the wheel?

    SSIS is the tool for this. But on the otherhand, 10.000 rows is not really much data. It should be quite fast. Reading this data should take only seconds, writing also.

    Wednesday, January 13, 2016 2:57 PM

All replies

  • Can you describe what you want to do? Also, what is your overall goal?

    As this is a .NET forum:

    A single SQL command "cannot be threaded to get the best performance". Cause a single SQL command needs to be started, then you'll need to wait for it to be finished. Threading does not help in this case.

    When you have multiple SQL commands, then the overall time span from starting the first command till the last is finished can be reduced, when each command is executed in its own thread. But as it is a Windows service, your commands should already run in its own thread.

    So I don't see here any potential for performace optimization.

    When talking about SQL: What is "a long SQL process"? SQL optimization has a lot of potential, but this has nothing to do with threads in regards to .NET.

    Wednesday, January 13, 2016 2:20 PM
  • I have SQL Server and MySQL.

    Every 15 minutes, Windows Service will read around 10,000 rows from SQL Server using SqlReader and then use While to INSERT the row in MySQL

    Wednesday, January 13, 2016 2:55 PM
  • Why reinventing the wheel?

    SSIS is the tool for this. But on the otherhand, 10.000 rows is not really much data. It should be quite fast. Reading this data should take only seconds, writing also.

    Wednesday, January 13, 2016 2:57 PM