On 02 Nov 2004 18:27:52 +0100, Harald Fuchs <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> 
> 
> >> Maybe you should explain what you're trying to achieve, not what you
> >> think how to do it.
> 
> > Sure.  I am using MySQL to store packets for transmission.  I want to
> > send the oldest, highest priority packets first.  Once I send it, I
> > don't want to resend it for at least 15 seconds so I have time to wait
> > for an acknowlegement.  Based on external events, I may exit the loop
> > before processing all the rows.  In this case, I only want to update
> > the timestamp on rows that I processed.  Any rows that I haven't
> > processed yet should keep the old timestamp.
> 
> I see.  Me thinks it's fundamentally unclean to iterate through a
> result set and changing rows while doing so.  You could remember the
> pkeys of the rows processed and then do a single
> 
>   UPDATE ... WHERE pkey IN (...)
> 
> after the loop, but maybe this might not be necessary at all: how
> about SELECTing only a single row (with LIMIT), processing that row,
> UPDATEing it, and all that within some loop?  You're doing more
> SELECTs that way, but with the proper indexes this might not be a
> problem.

I was originally using "limit 1" to do this processing.  However, I
could get all the records in the same amount of time as it took to get
one.  So, for example, I can process thousands of records in four
seconds or just one.

I did resolve my problem, however.  I  created a temporary database
connection to do the updates.

...Stephen

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to