What is more time-saving about SQL statement judgment and program judgment? Workaround
Source: Internet
Author: User
What is more time-saving about SQL statement judgment and program judgment?
What is more time-saving about SQL statement judgment and program judgment?
One
1,select if (age>10,name, ' ten ') as name from student; (MySQL SQL determines the name if the age is greater than 10)
2, cycle show at the front desk
Two
1,select name from student;
2, the program to determine the age of more than 10 and cycle display in the foreground
Ask:
On the first and second two methods, which is more time-saving? (Can not be limited to the above example)
------Solution--------------------
Self-test to see the next two methods of execution time soon don't know?
------Solution--------------------
SQL Fast, provided the age field is indexed.
Do you think that if you had 1 million records, you would read the array and traverse it?
------Solution--------------------
SQL is faster than program.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.