View Single Post

   
  #7 (permalink)  
Old 05-07-2008, 07:20 PM
Helmut Wais
 
Posts: n/a
Default Re: How to find holes in a sequence?

Steve Ackman wrote:
> In <41e20971-4fa0-41eb-9eff-b2bcddb1d6a5@d45g2000hsc.googlegroups.com>,
> on Tue, 6 May 2008 00:08:15 -0700 (PDT), cvh@LE,
> christian.hansel@cpi-service.com wrote:
>
>> I am abit surprised that running a shell script over a directory
>> should take so long.

>
> It takes ~34 minutes on this machine just to do this:
>
> #! /bin/sh
>
> i=3
> while [ $i -le 79389 ]
> do
> echo $i
> mysql news <<MARKER
> INSERT into count
> (id)
> VALUES
> ($i);
> MARKER
> i=$((i+1))
> done


which uses one DB connection and one mysql process for each row.

try this:

( i=3
while [ $i -le 79389 ]
do
echo "INSERT into count (id) VALUES ($i);"
i=$((i+1))
done
) | mysql news

regards, helmut
Reply With Quote