....... TableWarehouseActivityLine.RESET; TableWarehouseActivityLine.SETCURRENTKEY("Whse. Document No.","Whse. Document Type","Activity Type"); TableWarehouseActivityLine.SETRANGE("Whse. Document No.",TableWarehouseShipmentHeader."No."); TableWarehouseActivityLine.SETRANGE("Whse. Document Type",TableWarehouseActivityLine."Whse. Document Type"::Shipment); TableWarehouseActivityLine.SETRANGE("Activity Type",TableWarehouseActivityLine."Activity Type"::Pick) IF TableWarehouseActivityLine.FIND('-') THEN BEGIN TableWarehouseActivityLine.SETCURRENTKEY("Activity Type","No.","Line No."); IF TableWarehouseActivityLine.FIND('-') THEN; .......I have a dataset received by filtering on three fields and ordered by the key fileds, then I need to sort this dataset in order of primary key (Activity Type,No.,Line No.). Does changing the current key to primary run another query for retreiving another dataset with the filters already set but ordered by primary key or it use the same dataset and just reorder it? If it runs another query, this query won't be optimal as the key is not suitable for filters and SQL Server won't be able to retreive data quickly as it'll have to scan through entire table, will it? Is it a right way of changing sort orders?
Comments
So for SQL-server, this would be:
This of course, would go very bad on a Navision-server.
In this case (you can use this code also on SQL-server):
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Why do we have a cache then?
On the client, you have an Object-cache. This cache serves to cache the objects. When you run for example the customer-form the first time, the Navision client has to get the objects (form, table, other objects in those 2 and other objects in previous object, and so on ...) from the server. The client then keeps them in the object-cache so it doesn't need to get them the next time you access those objects. (at least if the object-cache is big enough to contain all of them and other objects you have run in the mean-time).
On the server, you have a DB-cache to avoid that SQL- or Navision-DB-server has to read always from the disk. I noticed with a Navision-DB-server with enough DB-cache that about 90% of the reads come from the DB-cache and 10% come from the disks.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
For this, create an index "Line No.", BUT DO NOT MAINTAIN IT IN SQL! It serves only for the Navision-SETCURRENTKEY.
For the other part, this code is even better, because it read every record only once from the DB and then puts it in a temptable from where reading is a lot faster.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!