Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/wp-db.php on line 668

Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-theme.php on line 544

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /usr/home/bugyo/public_html/b-log/wp-includes/comment-template.php on line 1739

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-block-list.php on line 199

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-term.php on line 198

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/class-wp-term.php on line 198
[MT4.2] 再構築時にデータベースへの問い合わせにかかる時間 – B-LOG
B-LOG

[MT4.2] 再構築時にデータベースへの問い合わせにかかる時間

MovableTypeではページの生成に非常に時間がかかる。

mod_perlやFastCGIを導入すればバイトコンパイルにかかる時間分を短縮できるが、再構築は分単位で時間がかかる処理のため、バイトコンパイルにかかる時間は無視できる程度になってあまり効果が出ないと思われる。

MTからデータベースへのクエリの発行回数を減らす (mt-search.cgiを例にとって)。』ではデータベースへの問い合わせ回数を減らすことでページの生成時間を減らそうとしているが、アムダールの法則で、問い合わせにかかる時間が全体のうちに占める割合で効果が限定される。

自分の環境ではどうだろうかと思ってデータベースへの問い合わせにかかる時間を計ってみることにした。

環境は

CPU Celeron 2.0GHz
chip set i865G
memory PC2700 768MB
OS FreeBSD 7.2
DBMS MySQL 5.0.77_1
MovableType 4.2.61

という感じで、ウェブサーバと同じマシンでmysqldを動かしている。

index_page.log
インデックスページのみを再構築したときのクエリログは上のようになった。

全体で449クエリ。そのうちSELECTが437クエリ、UPDATEが4クエリ、SETが8クエリ。

次にこのログを元にインデックスページ再構築時と同じクエリ列(query.txt)を作って

% time mysql -u root -ppasswd databese < query.txt > /dev/null

のようにして問い合わせ時間を計測した。

結果

0.086u 0.053s 0:02.13 6.1%      125+1371k 0+0io 0pf+0w
0.100u 0.046s 0:02.19 6.3%      87+977k 0+0io 0pf+0w
0.106u 0.034s 0:02.22 5.8%      130+1432k 0+0io 0pf+0w
0.115u 0.023s 0:02.20 5.9%      88+1001k 0+0io 0pf+0w
0.067u 0.074s 0:02.23 5.8%      109+1236k 0+0io 0pf+0w

となって5回平均で2.19秒かかっていることになる。

再構築時間が最短で13秒かかっているので、オーバーヘッドを含めずに17%程度がデータベースへの問い合わせにかかっている。

オンデマンドに問い合わせているだろうから、データベースサーバを置くマシンを別にしても大差ないだろう。

問い合わせ時間が0秒になっても10秒以上かかっていて、今のところ影響は少ないけど2割を超えてくると注意する必要があるかもしれない。