That's a postgres problem, not a Ruby problem.  You said it takes
nearly 20 minutes when using the command line client.  Don't you think
that's a little excessive?  Actually, let me just inform you right now
that it's a lot excessive.  Ruby times out because it says, "Uh,
there's no reason it should be taking this long.  I quit."  And it's
right, there's no reason it should take that long.

I don't know what the problem is, but it's a problem with your db, not
Ruby.  There's probably a way to change the timeout in Ruby, so it
would in fact wait that long.  I'd look to fix your db first though.



On 5/17/05, rgilaard / few.vu.nl <rgilaard / few.vu.nl> wrote:
> Dear all,
> I'm using a ruby script to manipulate some database tables in postgresql 7.4.6
> running under freebsd.
> 
> The following query
> 
> create table as select ident,count(ident) as totnrchange from bookhistory group
> by ident
> 
> Takes almost 20 minutes to accomplish if I issue these commands from the psql
> client utility.
> 
> However, if I use ruby to do the same as in:
> 
> Res=conn.exec("create table as select ident,count(ident) as totnrchange from
> bookhistory group by ident")
> 
> I get the follwing error:
> 
> Maketestset.rb : 47: IN 'exec': could not receive data from server: Operation
> timed out (PGError) from maketestset.rb
> 
> I also notice when looking at the outcome of top, that the % the cpu is busy
> with the postgers process gradually decreases and after a certain time the cpu
> stops doing anything and I get this error message.
> 
> What could cause this? I'm suspecting ruby because when I normally do this in
> psql, the query finishes.
> I have to do it like this because this statement is in a for loop and gets
> repeated almost 300 times
> 
> Can anyone help with this one?
> Thanks in advance
> Robert
> 
>