|
TSnxfx
|
Feb 14 2006, 02:44 PM, updated 20y ago
|
|
I'm wondering which is better in term of speed and performance.
SQL$ = " select * myTable where 1=0 " Set myrecordset= New Recordset myrecordset.Open RecSource$, MainDb, adOpenStatic, adLockOptimistic myrecordset.AddNew myrecordset.Fields("name") = "James" myrecordset.Update myrecordset.Close
OR
SQL$ = "INSERT INTO myTable(name) VALUES('James')" myrecordset.Open SQL$, MainDb, adOpenStatic, adLockOptimistic
Please give views and opinions. Thankx.
|
|
|
|
|
|
rebel without a cause
|
Feb 14 2006, 05:01 PM
|
Getting Started

|
i'll say the second if all you want to do is just insert a record and do nothing else but then it's really hard to say cause it depends on what you want to achieve mainly cause the first method has its uses as well especially if you want to make an open transaction/connection.
|
|
|
|
|
|
SincerePrayer
|
Feb 14 2006, 05:15 PM
|
love to pray
|
nxfx, Is definitetly the second approach. The reason behind is - The server does not need to return the whole set of records back to the client and will never use by the client
- The server does not need to lock the whole returned records for the purpose of adding
- The round trip between server and client are lesser. Hence, the time needed is lesser.
Happy Coding
|
|
|
|
|
|
TSnxfx
|
Feb 15 2006, 08:16 AM
|
|
For the 1st "select * myTable where 1=0" , would it return the record even if the "where 1=0" which is false? Other than that I do agree with you.
|
|
|
|
|
|
SincerePrayer
|
Feb 15 2006, 10:23 AM
|
love to pray
|
nxfx, Yes, the database server will conduct a search and some processing on this empty SELECT. You won't see much performance hit on small application; but you will see big performance impact on multi-user and multiple hit application. This is good have a good habbit in writing good code. Remember, this tiny habbit does affect your programming skill and how people look at your skill. Happy Coding
|
|
|
|
|
|
TSnxfx
|
Feb 16 2006, 08:35 AM
|
|
Oic, thanks for the enlightenment.
|
|
|
|
|