pg_field_type first call is very slow
オープン
まだ誰も着手していません。
Bug
Extension: pgsql
Status: Needs Triage
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
Problem: function pg_field_type first call (after run php script) is very slow.
The following code:
$connection = pg_connect("...") or die('Cannot connect db');
$res = pg_query($connection, 'SELECT 100');
$time0 = microtime(true); pg_field_name($res, 0);
$out[] = '(query 1) pg_field_name() first call = '.number_format((microtime(true) - $time0) * 1000, 4).' мс';
$time0 = microtime(true); pg_field_size($res, 0);
$out[] = '(query 1) pg_field_size() first call = '.number_format((microtime(true) - $time0) * 1000, 4).' мс';
$time0 = microtime(true); pg_field_type($res, 0);
$out[] = '(query 1) pg_field_type() first call = '.number_format((microtime(true) - $time0) * 1000, 4).' мс';
$time0 = microtime(true); pg_field_type($res, 0);
$out[] = '(query 1) pg_field_type() second call = '.number_format((microtime(true) - $time0) * 1000, 4).' мс';
$res = pg_query($connection, 'SELECT 200');
$time0 = microtime(true); pg_field_type($res, 0);
$out[] = '(query 2) pg_field_type() first call = '.number_format((microtime(true) - $time0) * 1000, 4).' мс';
$time0 = microtime(true); pg_field_type($res, 0);
$out[] = '(query 2) pg_field_type() second call = '.number_format((microtime(true) - $time0) * 1000, 4).' мс';
print_r($out);
<?php
Resulted in this output:
Array (
[0] => "(query 1) pg_field_name() first call = 0.0069 мс"
[1] => "(query 1) pg_field_size() first call = 0.0031 мс"
[2] => "(query 1) pg_field_type() first call = 46.6821 мс" // FIRST CALL IS VERY SLOW (pg_field_type)
[3] => "(query 1) pg_field_type() second call = 0.0050 мс"
[4] => "(query 2) pg_field_type() first call = 0.0069 мс"
[5] => "(query 2) pg_field_type() second call = 0.0029 мс"
)
But I expected this output instead:
Array (
[0] => "(query 1) pg_field_name() first call = 0.0069 мс"
[1] => "(query 1) pg_field_size() first call = 0.0031 мс"
[2] => "(query 1) pg_field_type() first call = 0.0050-0.0069 мс" // MUST BE
[3] => "(query 1) pg_field_type() second call = 0.0050 мс"
[4] => "(query 2) pg_field_type() first call = 0.0069 мс"
[5] => "(query 2) pg_field_type() second call = 0.0029 мс"
)
PHP Version
PHP 8.1
Operating System
Debian 11 (bullseye)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
PHP 8.1 と PostgreSQL で、提供された PHP の再現コードを pg_connect()、pg_query()、pg_field_type() とともに使い、最初の呼び出しとそれ以降の呼び出しを比較することから始めます。最初の呼び出しに約 46 ms かかる理由を特定するため、PostgreSQL のフィールド型検索パスを追跡します。完了の条件は、最初の呼び出しに原因不明の遅延がなくなり、観測された時間がリグレッションチェックでカバーされていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php, postgresql
- 領域
- backend, databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100