pg_field_type first call is very slow
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 103
Mô tả
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)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với bản tái hiện PHP được cung cấp bằng cách sử dụng pg_connect(), pg_query() và pg_field_type() trên PHP 8.1 với PostgreSQL, so sánh lần gọi đầu tiên với các lần gọi tiếp theo. Theo dõi đường dẫn tra cứu kiểu trường của PostgreSQL để xác định vì sao lần gọi đầu tiên mất khoảng 46 ms; được coi là hoàn tất khi lần gọi đầu tiên không còn độ trễ chưa được giải thích và thời gian quan sát được được bao phủ bởi một kiểm tra hồi quy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, php, postgresql
- Lĩnh vực
- backend, databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100