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

后端 未结 3 1671
春和景丽
春和景丽 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 have done things like this. It works relatively well. Note that each connection can handle exactly one query at a time so for each partition of your query, you have to have a separate connection. Now, in C# you could use threads to interact with each connection.

    But another option would be to use asynchronous queries and have a single thread manage and poll your entire connection pool (this sometimes simplifies data manipulations on the application side). Note in this case you are best ensuring a sleep or other yield point after every poll cycle.

    Note further that the extent to which this speeds the query depends on your disk I/O subsystem and your CPU parallelism. So you cannot just throw more pieces of a query and expect a speed up.

提交回复
热议问题