SELECT different rows on multiple threads

  • Lambert Antonio

    SSChasing Mays

    Points: 640

    I have an application which will be reading from a single table, in order to speed up the processing of each row it will run multiple threads, as soon as each thread finishes it will read again from the same table.

    My first approach is to select the rows assigned to an index of each thread by using modulus on the where clause

    SET @maxThreads = 10

    SELECT TOP 1 * FROM Table1 WHERE id % @maxThreads IN (0, @maxThreads)

    Any idea how else I can accomplish this?


    slow down when you need to hurry, stop when you need to move on,
    look back when you need to forget, or you might slip and leave sanity

  • John Mitchell-245523

    SSC Guru

    Points: 148667

    Why are you looking for an alternative approach - does yours not work?  What processing do you do on each row once you've selected it?

    John

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply