performance question: resultset's vs sql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Jay Johansen

    #1

    performance question: resultset's vs sql

    Does anyone know what the relative performance would be of using updateable
    result sets versus using individual insert or update statements?
    (Specifically at the moment I'm dealing with JSP programs using J/Connector
    on Tomcat, if that matters.) For example, if I want to read ten records and
    update them, would I be better off to use an updateable result set and
    update each as I go, or to issue UPDATE statements for each? (Intuitively it
    seems to me that the ResultSet should be faster, but who knows?) Similarly,
    if I want to insert 10 records, would I be better off to issue 10 INSERT
    calls, or to create an empty Result Set and then add records to it?

    Another efficiency question: I'm working on a JSP program where I build a
    display based on a select, the user fills in some fields that relate to each
    record, and then when Submit is pressed I re-read the records and do my
    processing. I was just assuming because it sounded right to me that I am
    better off to SELECT all the records, get the result set back, and then loop
    through, matching the records read against the fields off the web form, and
    whenever I see that I have to do something, I go off and do it (updating
    various tables based on input). But it occurs to me that an obvious
    alternative, and easier to code, would have been to loop through the web
    form fields, for each do a select that retrieves that one record, and then
    process it. That is, it seems to me intuitively that I am better off to do
    one select that retrieves 100 records and loop through the result set
    processing them, rather than to do 100 queries that each retrieve 1 record.
    Is this true?

    Thanks for any help!

    --
    MySQL General Mailing List
    For list archives: http://lists.mysql.com/mysql
    To unsubscribe: http://lists.mysql.com/mysql?unsub=m...ie.nctu.edu.tw

Working...