Can I split a query in multiple queries or create parallelism to speed a query?

后端 未结 3 1634
春和景丽
春和景丽 2021-01-11 18:04

I have a table avl_pool, and I have a function to find on the map the link nearest to that (x, y) position.

The performance of this select

3条回答
  •  执笔经年
    2021-01-11 18:32

    I've done this with SSIS by creating a script that buckets each server into 7 different "@Mode" (In my case the many servers assigns @Mode based on the last three digits of their IP -- this creates fairly evenly distributed buckets.

     (CONVERT(int, RIGHT(dbserver, 3)) % @stages) + 1 AS Mode
    

    In SSIS, I have 7 sets of the same 14 large queries running. Each are assigned a different @Mode number that is passed to the stored procedure.

    Essentially this allows for 7 simultaneous queries that never run on the same server and effectively cutting the runtime down by approx 85%.

    So, Create an SSIS package with the first step of refreshing the @Mode table.

    Then create a container that contains 7 containers. Within each of those 7 containers execute your SQL queries with Parameter Mapping to @Mode. I point everything to stored procs, so in my case the SQLStatement field reads something like: EXEC StoredProc ?. The ? will then check the Parameter Mapping you created for @Mode.

    Finally, in the SQL query, be sure that @Mode is indicated as a variable for which server to run the query against.

提交回复
热议问题