?
Solved

Which is Faster?

Posted on 2000-02-22
8
Medium Priority
?
230 Views
Last Modified: 2010-05-18
Which is faster when accessing a large table.
rst1.open "Select * from Table1 where 1 =2"
rst1.addnew
xx
xx
rst1.update

or

rst1.open "Table1"
rst1.addnew
xx
xx
xx
rst1.update

So does the select table or just table work faster.
0
Comment
Question by:jtjcomp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 200 total points
ID: 2546754
(blind guess) The second is faster, as it does not require the server to interpret and execute an SQL statement.
0
 
LVL 1

Author Comment

by:jtjcomp
ID: 2546771
If i open the table without the select statement will i still have access to all of the fields.
rst1.open "Select * from -- gives me all fields
rst1.open "Table1" -- Does it give me all fields?
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2546804
Normally "Table1" should be slightly faster, however there are other ways to improve performance, for instance:

Dim arrVal(1)
Dim arrFields(1)
    Dim rs As New ADODB.Recordset
    arrVal(0) = 15
    arrVal(1) = 65
    arrFields(0) = 0
    arrFields(1) = 1
    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenKeyset
    rs.LockType = adLockOptimistic
    rs.Open "table1", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My Documents\db1.mdb;Persist Security Info=False", , , adCmdTable
    rs.AddNew arrFields, arrVal
    rs.Update

is faster than

..addnew
xx
xx
xx
..update

Especially when you are working with large tables while you only want to add records, not opening a recordset is fastest, like:

Dim cn as new adodb.connection
cn.open "See above for example"
cn.Execute "Insert into table1 values (" & xx & ", "& xx & ", "& xx & ")", ,adExecuteNoRecords

though I don't know how comfortable you are with SQL

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2546808
Both your options give you all the fields.

caraf_g: you're quite good at blind guessing ;-)
0
 
LVL 1

Author Comment

by:jtjcomp
ID: 2546828
Thanks guys

I'm giving the points to caraf_g because it was the answer to my first question..

P Biggelaar, your suggestion was great but i think a little overkill for what i'm doing.

Thanks again.....
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2546847
Don't know what you're doing so: could be, maybe you can use it somewhere in the future.

You are right about giving the points to caraf_g: he was first and correct
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2546853
Huh? Wait.... it *was* just a blind guess. Did someone do a bench test? I don't understand what earned me those points.... though I like it, of course <g>
0
 
LVL 1

Author Comment

by:jtjcomp
ID: 2546862
Your blind guess and then p biggelaar's backing gets you the points..

:)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question