Expression Column Or SQL Query

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
 
S

Shawn Wildermuth (C# MVP)

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top