Below are some tips, using which we can optimise the mysql queries.
- Use EXPLAIN to determine queries are functioning appropriately.
- Test your queries often to see if they are performing optimally
- Use GROUP BY instead of DISTINCT when appropriate.
- Use indexed columns in WHERE, GROUP BY, and ORDER BY clauses
- Use a LIMIT on UNION instead of OR for less than 5 indexed fields.
- Use a indexed field and ORDER BY instead of MAX.
- Avoid using ORDER BY RAND().
- Minimize the data in your query to only the data you need, using * is overkill most of the time.
- Consider persistent connections instead of multiple connections to reduce overhead.
The 2 major types of table storage engines for MySQL databases are InnoDB and MyISAM. To summarize the differences of features and performance,
- InnoDB is newer while MyISAM is older.
- InnoDB is more complex while MyISAM is simpler.
- InnoDB is more strict in data integrity while MyISAM is loose.
- InnoDB implements row-level lock for inserting and updating while MyISAM implements table-level lock.
- InnoDB has transactions while MyISAM does not.
- InnoDB has foreign keys and relationship constraints while MyISAM does not.
- InnoDB has better crash recovery while MyISAM is poor at recovering data integrity at system crashes.
- MyISAM has full-text search index while InnoDB has not.
In light of these differences, InnoDB and MyISAM have their unique advantages and disadvantages against each other. They each are more suitable in some scenarios than the other.
Kindly have a look at the sequence of events that take place when you visit a URL below,
1. You enter a URL into the browser
2. The browser looks up the IP address for the domain name
3. The browser sends a HTTP request to the web server
4. The facebook server responds with a permanent redirect
5. The browser follows the redirect
6. The server ‘handles’ the request
cURL is a library that lets you make HTTP requests in PHP. Everything you need to know about it (and most other extensions) can be found in the PHP manual. In order to use PHP’s cURL functions you need to install the » libcurl package. PHP requires that you use libcurl 7.0.2-beta or higher.
For basic curl example, click here