Hi Dan,

<Sending this to general list too since it's not a Windows specific
question.>

Just run the UPDATE with all the column you want to update. :-)  MySQL
won't update the ones that haven't changed (which may have been said).
Don't waste time trying to determine whether you should include a column
in the UPDATE or not.

The only time it could be an issue is if you're setting a column to a
*REALLY* long value.  It will take longer to send the query to the
server (especially over a network) and MySQL will take a little more
time to parse it.


Hope that helps.


Matt


----- Original Message -----
From: "Daniel Canham"
Sent: Monday, January 12, 2004 2:48 AM
Subject: Re: query efficiency


> Thats not really what I meant.  I have 5 (or whatever) columns in a
table.
> I need to update values changed in those columns during processing.
But I
> have no way of knowing what column values need updating.  Is it worth
my
> while to write a dirty field checker (value has changed) or doesn't
the
> mysql engine care on UPDATE whether it is UPDATEing 1 or all 10
columns.
> The way you have it, you are doing all UPDATEs in one statement, or
each
> column on a seperate UPDATE.  In that case obviously it is faster to
run one
> update.  My question was is it more efficient to execute an single
statement
> UPDATE that has just the changed columns, or a single statement UPDATE
that
> contains all columns every time because the mysql engine treats them
the
> same.
>
> -Dan
>
>
>
>
> -----Original Message-----
> From: robert_rowe [mailto:[EMAIL PROTECTED]
> Sent: Saturday, January 10, 2004 1:17 PM
> To: [EMAIL PROTECTED]
> Subject: [mysql] Re: query efficiency
>
>
>
> By the way, MySQL won't actually do the update is the existing value
is the
> same as what is already in the fields. Try something like this:
>
> <pseudocode>
> print now
>
> for i=1 to 10000
> update table1 set col1=i+4, col2=i+3,col3=i+2,col4=i+1,col5=i;
> next i
>
> print now
>
> for i=1 to 10000
> update table1 set col1=i+4
> update table1 set col2=i+3
> update table1 set col3=i+2
> update table1 set col4=i+1
> update table1 set col5=i
> next i
>
> </pseudocode>
>
> I suspect that the first way will be faster.


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

Reply via email to