Efficiency
I've never stumbled on any discussion of efficiency of various methods of coding, although I have found posts on various forums where individuals were concerned with efficiency. I'm not concerned when dealing with user typing, but I am if a procedure is called by a query.
Does the VBA compiler generate "in-line" code for some apparent function calls? For example, y = Abs(x) might be compiled as y = x & mask. The string functions Left, Right, and Mid might also be compiled into compact code, and not be functions at all. Seems like y = x and y = Left(x, 4) might compile to Move Addrss x, Lenth = Len(x) to Address y or Move Address x, Length = 4 to Address y. No time/efficiency difference.
Second efficiency question. I have a table with 100K records, one field is "Selected", a boolean field. To clear all selected items, I run an update query. Which is better? If one is better, where is the break point. Obviously if Selected is 99% of the table size, it is better to just change all to false. Is there a method to determine any of this for Update Queries?
1st case tests all 100K records, but only changes those that are =True. The 2nd case doesn't need to test for any condition, but must change all 100K records to False.
I've never stumbled on any discussion of efficiency of various methods of coding, although I have found posts on various forums where individuals were concerned with efficiency. I'm not concerned when dealing with user typing, but I am if a procedure is called by a query.
Does the VBA compiler generate "in-line" code for some apparent function calls? For example, y = Abs(x) might be compiled as y = x & mask. The string functions Left, Right, and Mid might also be compiled into compact code, and not be functions at all. Seems like y = x and y = Left(x, 4) might compile to Move Addrss x, Lenth = Len(x) to Address y or Move Address x, Length = 4 to Address y. No time/efficiency difference.
Second efficiency question. I have a table with 100K records, one field is "Selected", a boolean field. To clear all selected items, I run an update query. Which is better? If one is better, where is the break point. Obviously if Selected is 99% of the table size, it is better to just change all to false. Is there a method to determine any of this for Update Queries?
Code:
UPDATE Table SET Table.Selected = False WHERE (((Table.Selected)=True)); UPDATE Table SET Table.Selected = False;
Comment