Показать сообщение отдельно
Старый 31.07.2007, 15:00   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
axcoder: Unwanted fields fetching when selecting by unique index
Источник: http://axcoder.blogspot.com/2007/07/...selecting.html
==============

Last friday i was optimizing a form with a lof of display fields with an implementation like the following:

X++:
display EmplName emplName()
{
  return EmplTable::find(this.EmplID).Name;
}
The one of sources to increase performance of such code is to select only fields which will be used lately. So I have replaced this code with the following:

X++:
display EmplName emplName()
{
  return this.EmplID ?
         (select Name from EmplTable
              where EmplTable.emplID==this.EmplID).Name
         :
         "";
}
but when I enabled SQL tracing, I found, that this code producess select with ALL fields of EmplTable.
It was strange... With a great help of my co worker, i've found the following:
  • when there is only fields of any unique index in the where condition, all fields are fetched
  • when there is an extra field in the condition, only required fields is selected (and the extra fields in where)
  • So I converted previously mentioned methods to the following:

X++:
display EmplName emplName()
{
  return this.EmplID ?
         (select Name from EmplTable
              where EmplTable.emplID==this.EmplID
                     &&
                     EmplTable.recID
          ).Name
         :
         "";
}

Источник: http://axcoder.blogspot.com/2007/07/...selecting.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.