-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/pgsql: adding pg_result_memory_size. #14214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--TEST-- | ||
pg_result_memory_size | ||
--EXTENSIONS-- | ||
pgsql | ||
--SKIPIF-- | ||
<?php | ||
include("inc/skipif.inc"); | ||
if (!function_exists('pg_result_memory_size')) die('skip function pg_result_memory_size() does not exist'); | ||
?> | ||
--FILE-- | ||
<?php | ||
include('inc/config.inc'); | ||
|
||
$db = pg_connect($conn_str); | ||
|
||
$result = pg_query($db, 'select 1'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: is the memory usage deterministic right ? If that s the case if I redo this query it should be the same amount correct ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The memory usage returned by
Based on some tests with simple queries, the memory usage has been consistent when none of these variables are at play. However, I must note that I am not deeply familiar with the internal implementation of (For the above reasons, I did not write the output size directly in the test, but instead tested by comparing the two results) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the detail but what I meant if within your test if I do $result = pg_query($db, 'select 1');
$size_3 = pg_result_memory_size($result);
var_dump($size_1 == $size_3); it should be true then ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, |
||
$size_1 = pg_result_memory_size($result); | ||
|
||
$result = pg_query($db, "select generate_series(1, 10000) as i, repeat('string', 100)"); | ||
$size_2 = pg_result_memory_size($result); | ||
|
||
var_dump($size_1); | ||
var_dump($size_2); | ||
var_dump($size_1 < $size_2); | ||
?> | ||
--EXPECTF-- | ||
int(%d) | ||
int(%d) | ||
bool(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE:
PostgreSQL: Documentation: 12: E.20. Release 12
https://www.postgresql.org/docs/12/release-12.html#id-1.11.6.24.5.9