2

Having a hard time understanding why PostgreSQL from google cloud services is taking > 400 ms for any simple query (~4-row table) from my PHP code using PDO or pg driver. IP ping averages around 60 ms so it seems it's not a distance problem. Using both PGAdmin and PHP yield around a 400+ ms response time.

$before_conn1 = microtime(true);
$result = pg_query($connector->conn(),$query);
$after_conn1 = microtime(true);

$test = $after_conn1 - $before_conn1;
echo $test;return;

// response time 0.46275 unix timestamp

query looks like this:

SELECT id,clearance from table

literally the table has 4 rows and 2 columns.

8
  • What is the time for select 123; query? Also, maybe you should edit and post your exact query here, but change names (to prevent security leak). Commented Apr 19, 2021 at 18:55
  • 1
    @Top-Master, thanks for the prompt response. Select 123 took 0.4780 Commented Apr 19, 2021 at 19:12
  • Then it seems to be an intentional limitation (from Google side), maybe see another post about this same matter Commented Apr 19, 2021 at 19:21
  • What is $connector->conn() doing? Does it make a fresh connection? If so, do you use a connection pool? Commented Apr 19, 2021 at 19:31
  • Maybe try again and exclude the time of $connector->conn() method (by storing it's result in a variable, before $before_conn1 = ... line). Commented Apr 19, 2021 at 19:36

1 Answer 1

1

Seems the lag was caused by the PDO driver. I'm not sure exactly why but ended up using pg_query for a single query and pg_send_query for batch selects with the asynchronous response which worked really well! Hope this helps others.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.