Thread: Large delay in pgsql-jdbc SELECT

Large delay in pgsql-jdbc SELECT

From
"Jackson, Scott M"
Date:
Hello,

I am hoping somebody might have an idea about this or a suggestion for
troubleshooting...

I am using jdbc7.1-1.2.jar with jdk1.3.1_01 on an i386 box with RedHat 7.1.

When running a SELECT query that resulted in 10 rows of 100 columns each, I
could average a 1 second response from my application.
However when I ran a similar SELECT that resulted in 100 rows of 100 columns
each (of exactly the same format), I experienced a very definitive hang of
about 20-25 seconds.

When I issued the same query within the psql prompt, the query results
returned immediately.

My application is hanging at the db.createStatement().executeQuery("SELECT
..."); statement
I turned on level 4 debugging and straced -f my postmaster and saw that it
was hanging in a recv statement in file descriptor 5 which is the
/usr/local/pgsql/data/global/pg_control file.

Debug and strace output at the hang is:

......
[pid 24706] 11:40:25 brk(0x8237000)     = 0x8237000
[pid 24706] 11:40:25 write(2, "DEBUG:  CommitTransactionCommand"...,
33DEBUG:  CommitTransactionCommand
) = 33
[pid 24706] 11:40:25 brk(0x8213000)     = 0x8213000
[pid 24706] 11:40:25 send(5,
"\0051\0\0\0\0051\0\0\0\0051\0\0\0\0051\0\0\0\0051\0\0\0"..., 1327, 0) =
1327
[pid 24706] 11:40:25 recv(5,

(It hangs here for 20 seconds)

"Qcommit\0", 8192, 0) = 8
[pid 24827] 11:43:09 write(2, "DEBUG:  StartTransactionCommand\n", 32DEBUG:
StartTransactionCommand
) = 32
[pid 24827] 11:43:09 write(2, "DEBUG:  query: commit\n", 22DEBUG:  query:
commit) = 22
...


Top appears to reveal no memory problems, I have all my limits set to
unlimited. I see a very high level of CPU activity during this period.

Does anyone have any thoughts or recommendations?

Thanks for any help you can give me!

Scott Jackson

Re: Large delay in pgsql-jdbc SELECT

From
Barry Lind
Date:
Turn on query logging on the server and run the exact same query that
jdbc is sending in psql.  I suspect you will see the same issue in psql
as well.  The info you have included below indicates that the server is
just taking a long time to run the query.

--Barry





Jackson, Scott M wrote:

>Hello,
>
>I am hoping somebody might have an idea about this or a suggestion for
>troubleshooting...
>
>I am using jdbc7.1-1.2.jar with jdk1.3.1_01 on an i386 box with RedHat 7.1.
>
>When running a SELECT query that resulted in 10 rows of 100 columns each, I
>could average a 1 second response from my application.
>However when I ran a similar SELECT that resulted in 100 rows of 100 columns
>each (of exactly the same format), I experienced a very definitive hang of
>about 20-25 seconds.
>
>When I issued the same query within the psql prompt, the query results
>returned immediately.
>
>My application is hanging at the db.createStatement().executeQuery("SELECT
>..."); statement
>I turned on level 4 debugging and straced -f my postmaster and saw that it
>was hanging in a recv statement in file descriptor 5 which is the
>/usr/local/pgsql/data/global/pg_control file.
>
>Debug and strace output at the hang is:
>
>......
>[pid 24706] 11:40:25 brk(0x8237000)     = 0x8237000
>[pid 24706] 11:40:25 write(2, "DEBUG:  CommitTransactionCommand"...,
>33DEBUG:  CommitTransactionCommand
>) = 33
>[pid 24706] 11:40:25 brk(0x8213000)     = 0x8213000
>[pid 24706] 11:40:25 send(5,
>"\0051\0\0\0\0051\0\0\0\0051\0\0\0\0051\0\0\0\0051\0\0\0"..., 1327, 0) =
>1327
>[pid 24706] 11:40:25 recv(5,
>
>(It hangs here for 20 seconds)
>
>"Qcommit\0", 8192, 0) = 8
>[pid 24827] 11:43:09 write(2, "DEBUG:  StartTransactionCommand\n", 32DEBUG:
>StartTransactionCommand
>) = 32
>[pid 24827] 11:43:09 write(2, "DEBUG:  query: commit\n", 22DEBUG:  query:
>commit) = 22
>...
>
>
>Top appears to reveal no memory problems, I have all my limits set to
>unlimited. I see a very high level of CPU activity during this period.
>
>Does anyone have any thoughts or recommendations?
>
>Thanks for any help you can give me!
>
>Scott Jackson
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://archives.postgresql.org
>
>
>