Expression Column Or SQL Query

  • Thread starter Thread starter Steve, Putman
  • Start date Start date
S

Steve, Putman

Hi Gurus,
Keeping it short - Suppose I have a Table with two columns- Column1 and
Column2, and it got lots of data.
Now I want to create another column(Column3) joining Column1 and Column2.

I can do it in two ways,
1. Doing SQL "Select Column1+Column2 as [Column3] From TableName".
2. Or add a expression column on the Datatable "Column1+Column2".

I want to know which one is better and preffered to use,
Performance wise which is better.

Please help me. I will appreciate your help.
Thanks, Steve
 
Hello Putman,

I think (though I don't have the numbers to back it up anymore) is that the
SQL would be faster. The real benefit with calculated columns is for changing
data in that you can get the calculated values at runtime before having to
go back to the DB.


Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
 
It might depend on how/where you use the column3 field. Having it as a third
column in the datatable (populating it from the sql query) might add overhead
to the amount of data passed over the network and also consume memory.

concatenating the fields on the fly might add overhead to the memory (by
creating objects).

am i right?

Shawn Wildermuth (C# MVP) said:
Hello Putman,

I think (though I don't have the numbers to back it up anymore) is that the
SQL would be faster. The real benefit with calculated columns is for changing
data in that you can get the calculated values at runtime before having to
go back to the DB.


Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
Hi Gurus,
Keeping it short - Suppose I have a Table with two columns- Column1
and
Column2, and it got lots of data.
Now I want to create another column(Column3) joining Column1 and
Column2.
I can do it in two ways,
1. Doing SQL "Select Column1+Column2 as [Column3] From TableName".
2. Or add a expression column on the Datatable "Column1+Column2".
I want to know which one is better and preffered to use, Performance
wise which is better.

Please help me. I will appreciate your help.
Thanks, Steve
 
Back
Top