Why is database considered the best place to apply conditional logic?

Why is database considered the best place to apply conditional logic?
d2marceloAsked:
Who is Participating?
 
Kent OlsenConnect With a Mentor Data Warehouse Architect / DBACommented:
The database can process the query, returning exactly the data needed without imposing that logic into a program or putting unnecessary data on a network.

Imagine a table with 1,000,000 row and your query needs the row with an ID value of 712.  The database can find a single row and return it simply by placing the clause WHERE id=712 on the query.  This may well be an index scan and if the required data is in the index, it's not even necessary to read the data row.

By contrast, if the logic were put into a program, it would have to read all 1,000,000 rows, discarding the data it doesn't want.


Pushing logic down to as low a level as possible is usually a good idea.



Good Luck,
Kent
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.