[colug-432] Bash fun

Stephen P Potter spp at unixsa.net
Sun Nov 1 15:14:02 EST 2009


Tom Hanlon wrote:
> Thanks Matt,
>
> Good to know that eval is not needed.
>
> Another question, suppose I wanted to throttle this script.
>
> I want to run only 10 requests for second ?
>
> Part of the issue is this will spawn one mysql connection per line.
>
> The connection will be immediately dropped but we would still face:
> 	authentication, thread generation , execution , disconnect.
> 	authentication, thread generation , execution , disconnect.
> 	authentication, thread generation , execution , disconnect.
>
> Rather than.
> 	authentication, thread generation
> 		execution
> 		execution
> 		execution
> 		......
> 	disconnect
> 		
>
>
>
>
> Unfortunate but I do not know how to batch explain from inside mysql.
>
> MySQL does take batch jobs as  source.sql > mysql >>outfile.txt
>
> So I might try and work it that way.
>
> Batch 100 lines, connect and run,
>
> Batch 100 lines, connect and run.
>
> If I find I have to run this on a production box.. well it would be  
> nice to not spawn one mysql connection per line.
>   
You said your are taking all your input from a pre-existing file, 
correct?  In that case, the batch nature of mysql means that each query 
will be run sequentially in a single connection to the database.  It 
doesn't make any significant different to batch 100 at a time versus 
running them all sequentially (unless you really mean batch; sleep; 
batch; sleep; batch).  Also, you want either "cat source.sql | mysql" or 
"mysql < source.sql" not "source.sql >mysql".

-spp


More information about the colug-432 mailing list