A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Field Name Speed?



 
 
Thread Tools Display Modes
  #1  
Old April 19th, 2010, 02:16 PM posted to microsoft.public.access
David[_62_]
external usenet poster
 
Posts: 13
Default Field Name Speed?

I've read that when using access fields that:

rstOrders.Fields("fldCustomer")

is faster than

!fldCustomer

=================
Question

Is this true, and if so why?

Thanks
David


  #2  
Old April 19th, 2010, 02:26 PM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Field Name Speed?

hi David,

On 19.04.2010 15:16, David wrote:
I've read that when using access fields that:
rstOrders.Fields("fldCustomer")
is faster than
!fldCustomer

Is this true, and if so why?

Go and search for 'dot vs bang'...

It's basically caused by the fact that the bang'ed access must be
resolved at runtime and this is a little bit more complex than
enumerating a collection and returning a value.

mfG
-- stefan --
  #3  
Old April 19th, 2010, 02:47 PM posted to microsoft.public.access
David[_62_]
external usenet poster
 
Posts: 13
Default Field Name Speed?

Thanks Mr. Hoffmann for responding.

Are you saying "bang" is late-bound versus Field early-bound.
If so, do you know any article or MSDN reference that refers to this --
or -- the best way to test it?

David

"Stefan Hoffmann" wrote in message
...
hi David,

On 19.04.2010 15:16, David wrote:
I've read that when using access fields that:
rstOrders.Fields("fldCustomer")
is faster than
!fldCustomer

Is this true, and if so why?

Go and search for 'dot vs bang'...

It's basically caused by the fact that the bang'ed access must be resolved
at runtime and this is a little bit more complex than enumerating a
collection and returning a value.

mfG
-- stefan --



  #4  
Old April 19th, 2010, 02:57 PM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Field Name Speed?

hi David,

On 19.04.2010 15:47, David wrote:
Are you saying "bang" is late-bound versus Field early-bound.
If so, do you know any article or MSDN reference that refers to this --
or -- the best way to test it?

Take a closer look at

http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

seems that I've also mixed it up.


mfG
-- stefan --
  #5  
Old April 19th, 2010, 03:12 PM posted to microsoft.public.access
David[_62_]
external usenet poster
 
Posts: 13
Default Field Name Speed?

Thanks for link. Been searching MSDN without any luck.

Using Me.("Customer") logically makes sense that it would be slower since a
string needs to be allocated versus referring to the field name directly.

Unfortuantely they did not specifically address the Fields collection.
Whether the logic prevails is a ?

David


"Stefan Hoffmann" wrote in message
...
hi David,

On 19.04.2010 15:47, David wrote:
Are you saying "bang" is late-bound versus Field early-bound.
If so, do you know any article or MSDN reference that refers to this --
or -- the best way to test it?

Take a closer look at

http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx

seems that I've also mixed it up.


mfG
-- stefan --



  #6  
Old April 20th, 2010, 07:19 AM posted to microsoft.public.access
david
external usenet poster
 
Posts: 398
Default Field Name Speed?

When using Access fields,

Set fld = rstOrders.Fields("fldCustomer")

for i = 1 to 100000
rstOrders.AddNew
fld = str(i)
rstOrders.Update
next

is much faster.

Although record update loops are a very old technique, once
used mostly by old dBase programmers. Mostly you can use
an Update Query to update a lot of records.

Don't know why it is called an Update Query. In other
RDMS's it would have been called a stored procedure.

(david)


"David" wrote in message
...
I've read that when using access fields that:

rstOrders.Fields("fldCustomer")

is faster than

!fldCustomer

=================
Question

Is this true, and if so why?

Thanks
David



  #7  
Old April 20th, 2010, 09:20 AM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Field Name Speed?

On 20.04.2010 08:19, david wrote:
When using Access fields,

Set fld = rstOrders.Fields("fldCustomer")
for i = 1 to 100000
rstOrders.AddNew
fld = str(i)
rstOrders.Update
next

is much faster.

This is basically true for all collections which can be bound like
fields, e.g.

Option Compare Database
Option Explicit

Declare Function GetTickCount Lib "kernel32.dll" () As Long

Public Sub Test()

Const MAX_COUNT As Long = 100000
Dim db As DAO.Database
Dim td As DAO.TableDef

Dim count As Long
Dim dummy As String
Dim tcStart As Long
Dim tcStop As Long

Debug.Print "---"
Set db = CurrentDb

tcStart = GetTickCount
For count = 1 To MAX_COUNT
dummy = db.TableDefs.item(0).Name
Next count
tcStop = GetTickCount
Debug.Print "Time elapsed:"; tcStop - tcStart; "ms"

Set td = db.TableDefs.item(0)

tcStart = GetTickCount
For count = 1 To MAX_COUNT
dummy = td.Name
Next count
tcStop = GetTickCount
Debug.Print "Time elapsed:"; tcStop - tcStart; "ms"

End Sub

Don't know why it is called an Update Query. In other
RDMS's it would have been called a stored procedure.

Only when you store it there, otherwise it may be called adhoc query.
Some DBA's are afraid of these


mfG
-- stefan --
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.