You can surely save on the number of calls being made to the database by joining the two tables in the while select instead of separate calls to the database for the while select followed by another select. If you do not use the index hint the database will choose an optimum index, provided that indexes exist and the database is configured to collect and update the statistics periodically.
Regards, Varden Morris 276 Taralake Terrace N.E. Calgary, Alberta T3J 0A1 Canada (403) 366-8434 (H) (403) 615-1604 (C) [EMAIL PROTECTED] ----- Original Message ---- From: James Flavell <[EMAIL PROTECTED]> To: Axapta-Knowledge-Village@yahoogroups.com Sent: Thursday, November 1, 2007 8:05:29 AM Subject: [Axapta-Knowledge-Village] select firstonly Hi again everyone, Thanks Christoph for the feebdack on index. I have added indexes just to play safe. Another query I have is with the firstonly command. I understand basically how it works but want to know how it really works in practice Given this code: while select WMSPallet order by WMSPalletId { select firstonly InventPalletBP where InventPalletBP. PalletId == WMSPallet.wMSPallet Id; } Is it better to use firstonly in such a situation? I mean I am going to be looping through pallets so if I dont use firstonly a number of inventpalletbp table records will be fetched together which in theory would be a good thing to save on database calls. But then i am wondering will the records that are fetched be in any particualr order (e.g. by palletid) or just from the same page in the SQL server? I guess it should be read ahead according to the where clause or do I need to explicitly put an order by or index command against the InventPalletBP select statement to be sure of this? Looking forward to your input Thanks James [Non-text portions of this message have been removed] __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com [Non-text portions of this message have been removed]