Select Statement Vs Find in Ax

2.3k views Asked by At

while writing code we can either use select statement or select field list or find method on table for fetching the records.

  I wonder which of the statement helps in better performance
2

There are 2 answers

0
ceth On

You can look at the find() method on the table and find out the same 'select'-statement there.

  • It can be the same 'select; statement as your own an the performance will be the same in this case.
  • And it can be different select statement then your own and the performance will be depend on indexes on the table, select statement, collected statistics and so on.

But there is no magic here. All of them is just select statement - no matter which method do you use.

0
Smur On

It really depends on what you actually need.

find() methods must return the whole table buffer, that means, all of the columns are projected into the buffer returned by it, so you have the complete record selected. But sometimes you only need a single column, or just a few. In such cases it can be a waste to select the whole record, since you won't use the columns selected anyway.

So if you're dealing with a table that has lots of columns and you only need a few of them, consider writing a specific select statement for that, listing the columns you need.

Also, keep in mind that select statements that only project a few columns should not be made public. That means that you should NOT extract such statements into a method, because imagine the surprise of someone consuming that method and trying to figure out why column X was empty...