Jump to content

Performance Question: recordset or sql script


paulnordstrom

Recommended Posts

Hello,Whenever I have wanted to add information to a database, I have always opened a recordset, addnew, set the fields = to the form values, update, close the recordset.Is this more intensive to the server than writing the sql script to do an INSERT INTO?I'm just getting into writing and executing sql scripts in an asp page and now im rethinking everything i ever thought...that ever happen to anyone else out there?Thanks,Paul

Link to comment
Share on other sites

Of course, that happens all the time. For example, these two queries are quite different:SELECT a.id, b.name FROM table1 a, table2 b WHERE ....SELECT a.id, b.name FROM table1 AS a, table2 AS b WHERE ....The first statement will make a copy of both tables, where the second statement will use a and b simply as aliases, and not copy the entire tables. The first statement is much more memory-intensive then the second one.As for your question, it might be worth it to run some tests. Have a loop that executes 1000 or 100000 or 1 million times, and have your statement to test inside the loop. Time the execution for each loop and figure out which one takes less time. The server will usually cache results, so you might have to use some random numbers or something to make sure that real results get returned each time, but that will probably give you the best idea about which one is quicker. If you have access to the server, you can also monitor the resources being used while the tests are running and try to determine which one uses more memory or CPU power.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...