Skip to content

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Oct 18, 2025

See individual commits.

@devnexen
Copy link
Member

do you think it s possible to do a "humanly noticeable benchmark" of these improvements ?

@nielsdos
Copy link
Member Author

I tried benchmarking this:

<?php
$conn_string = "host=localhost port=5432 dbname=test user=postgres password=postgres";
$conn = pg_connect($conn_string) or die("no");

$params = array_fill(0, 5, 'this is an input string for the pgsql query');
$query = 'SELECT $1,$2,$3,$4,$5';
for ($i = 0; $i < 5000; $i++) {
    $result = pg_query_params($conn, $query, $params);
}

But the noise is too high, the variance is huge. Most of the time (>60%) is spent in the kernel with only a few percentages in PHP itself. Running a perf shows that the time spent in pg_query_params halves. In any case, the memory usage (noticeable for long strings) should also decrease

@nielsdos nielsdos marked this pull request as ready for review October 18, 2025 11:26
@nielsdos nielsdos requested a review from devnexen as a code owner October 18, 2025 11:26
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea if you plan any further changes but looks fine as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants