Amazon Athena 可以透過 ODBC 連接了

Amazon Athena 支援 ODBC 了 (先前直接連結只支援 JDBC):「Amazon Athena adds support for querying data using an ODBC driver」。

With the availability of a new ODBC driver, you can now connect popular business intelligence tools to Athena. This allows you to report and visualize all of your data in S3 with the tools of your choice. In addition to the ODBC driver, Customers can now connect to Amazon Athena using a JDBC driver, an API and via the AWS Console.

這讓非 Java 的程式語言可以更方便的接上去了,像是 PHPPDO 支援 ODBC 但不支援 JDBC,要用就得想其他辦法:「PHP: PDO Drivers - Manual」。

有 Lazy Connection 功能的 PDO object

在「Aura.Sql」這邊看到有提供 Lazy Connection 的 PDO object,而且是繼承自本來的 PDO object:

Provides an extension to the native PDO along with a profiler and connection locator. Because ExtendedPdo is an extension of the native PDO, code already using the native PDO or typehinted to the native PDO can use ExtendedPdo without any changes.

Lazy connection. ExtendedPdo connects to the database only on method calls that require a connection. This means you can create an instance and not incur the cost of a connection if you never make a query.

之後可以拿來跟 LaravelEloquent 一起用看看。本來的 PDO 物件在建立時就會建立連線,對於連線的開銷其實蠻大的,用這個應該是個方向...

另外是 Profiler 的能力,需要用的時候應該會很好用:

Profiler. An optional query profiler is provided, along with an interface for other implementations, that logs to any PSR-3 interface.

引一下來源,當初是從「Atlas.Orm 2.0 Is Now Stable」這邊在看文件時一路看到的。

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 就可以支援受益...