MySQL 5.7 的 Pipeline 查詢加速

在「MySQL 5.7.12 – Part 2: Improving the MySQL Protocol」這邊看到介紹 MySQL 的 Asynchronous API,藉由 pipeline 加速查詢。

本來的:

res_1 = conn.query("DO 1");
res_2 = conn.query("DO 2");

會產生這樣的 flow:

而 Asynchronous API 可以這樣寫,先把兩個 SQL query 都丟出去,然後等結果:

hndl_1 = conn.query_send("DO 1");
hndl_2 = conn.query_send("DO 2");

# wait for completion
res_1 = conn.query_recv(hndl_1);
res_2 = conn.query_recv(hndl_2);

也就是產生這樣的 flow:

感覺 PHP 上只要 PDO 改善這塊後,各家 ORM library 就可以支援受益...

This entry was posted in Computer, Database, Murmuring, MySQL, Programming, Software and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *