views:

50

answers:

1

Hi everbody,

I have a general inquiry related to processing rows from a query. In general, I always try to format/process my rows in SQL itself, using numerous CASE WHEN statements to pre-format my db result, limiting rows and filling columns based on other columns.

However, you can also opt to just select all your rows and do the post-processing in code (asp.NET in my case). What do you guys think is the best approach in terms of performance?

Thanks in advance, Stijn

A: 

I would recommend doing the processing in the code, unless you have network bandwidth considerations. The simple reason for this is that is is generally easier to make code changes than database changes. Furthermore, performance is more often related to the actual database query and disk access rather than the amount of data returned.

However, I'm assuming that your are referring to "minor" formatting changes to the result. Standard where clauses should naturally be done in the database.

Bjorn
Thanks Bjorn. In my specific case, I create a few additional columns in my query result. These columns need to be filled based on values in other columns. I can eithe ruse CASE WHEN statements, or I can fill the extra columns in my asp.NET code. For maintenance purposes, I'm guessing the in-code option would indeed be the best
Stijn Van Loo