Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

That sounds like a good strategy, monsieur_champs. I just wanted to warn you away from trying to optimize a few hundredths of a second off an update - if you were going to query the database to compare the columns so you could only update the ones that changed, that would almost certainly take more time than updating all of them. If you have valid reasons for not updating some columns, however, that's something else entirely. You could always "cache" the original values in the form and compare the cached values to the new ones - but it is unlikely to be worth the trouble.

MrChromeDome raises a good point about updating indexes and keys (with constraints) - although I would argue it probably wouldn't matter for a single update on a single table. However, in a good database design the index will generally not change when you update a record (changing the index would change its essential identity, which would be logically equivalent to deleting the record and inserting another). Also, if the column is not really changing (you are setting it to the original value), the database should be smart enough to recognize that. Another thing to take into account (when updating many rows on databases that support it) is the possibility that there is an update trigger on the table, which may do different things depending on the column updated. If you are updating millions of records, triggers, indexes, and constraints can make a big difference.


In reply to Re: Re: Re: Record edition management strategy needed by bean
in thread Record edition management strategy needed by monsieur_champs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-04-19 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found