?
Solved

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

Posted on 2007-07-27
1
Medium Priority
?
576 Views
Last Modified: 2008-03-06
Why is database considered the best place to apply conditional logic?
0
Comment
Question by:d2marcelo
1 Comment
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 1500 total points
ID: 19583208
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
This video shows how to recover a database from a user managed backup
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question