Tuesday, June 5, 2012

MySQL Function That Programmers Often Ignore

| 0 comments

As a database, MySQL has a very nice ability to build an application. But sometimes, PHP programmers don't know (perhaps don't want to know) any function that can be done in MySQL. This will make the application run slower than it should.

Check The Statements Below, make sure you're not on the list


1. Treating query result as an array, and then use the loop just to get the count, instead using mysql "SELECTY COUNT (*)".

2. Filter data done in the PHP script
For example, we need to get the data with the value more than 80. We just need to filter with "WHERE value > 80". But if you don't know, you'll filter the data in the PHP code. Absolutely it makes the traffic get too high.

3. Not using DATE_FORMAT()
This facility can be used to fetch datetime field in the database in the format we want. But sometimes, we need a special treatment to the data, and that function is not enough. For example we need to display it not in English.

4. Not Using the LIMIT
This can make your application run slowly, even it can make the server down, especially when fetching large amount of data.

5. Don't know about Normalization

6. Not giving index to a field that frequently used as a key for searching.

7. Don't know about locking, concurrency and transaction

8. Lack of Data Type Optimization

9. Ignoring the table type

Perhaps those are very simple things, but some programmers don't know yet, and they have to rebuild the database to optimize the application.

0 comments:

Post a Comment