Hi Pierce, Thanks for the feedback. Yes, I did run into the timeout issue for heavy queries myself as well. I was already planning to add this option. https://github.com/svenvc/P3/commit/ce68fd206b47c0411b75f0992ef4f4e119eb4ff1 Added P3Client>>#timeout[:] option (thx Pierce Ng) Added P3ClientTests>>#testTimeout Refactored host/port/user/password/database into properties Now you can do the following: P3ClientTests>>#testTimeout "Reconnect with an explicit timeout" client close. client url: url. client timeout: 1. "second" self assert: client isWorking. "The following (sleeping for 0.5 seconds) should just pass successfully" client execute: 'SELECT pg_sleep(0.5)'. "While the following (sleeping for 1.5 seconds) should time out" self should: [ client execute: 'SELECT pg_sleep(1.5)' ] raise: ConnectionTimedOut About Zdc streams. They have their own default timeout (5 seconds). I think it is not a good idea to have global timeout setting, these should be done per actual (client) instance. I like relatively short timeouts, so that I get faster feedback. BTW, I am also interested in your experience using P3. How did it go ? Sven
On 26 Nov 2017, at 09:43, Pierce Ng <pierce@samadhiweb.com> wrote:
Hi Sven and all,
I have a PostgreSQL database running in a resource-light Linux VM with ~4 million rows consisting of mostly text. My query executes regexp_matches() on the text and it runs noticeably slowly.
I am encountering ConnectionTimedOut using P3 to run my query. PostgresV2 and Python's pg8000 do work though. I see that PostgresV2's PGConnection uses "Socket standardTimeout". I changed ZdcSimpleSocketStream class-side's #openConnectionToHostNamed:port: bottom part to add the same timeout because P3Client>>open calls it:
ZdcSimpleSocketStream class>>openConnectionToHostNamed: hostName port: portNumber [...] ^ socketStream timeout: Socket standardTimeOut; "<== added this line" connectTo: hostIP port: portNumber; yourself
Now my query returns instead of timing out.
It does look like ZdcSimpleSocketStream's three class-side methods could use some refactoring love.
Pierce