Changes
Title
changed
Performance - A Guide For Best Practisce
Category
unchanged
Tutorials
Yii version
unchanged
Tags
changed
performance
Content
changed
In this guide I will explain best practise regarding performance in MySQL, PHP and of course our loved Yii Framework. Since this is a complex topic, I will start with some basics and then expand this guide from time to time. Since this
cookbookwiki can become big, you may click on `
RevisionView history` - there you can see what changes have been made, so you don't miss anything.
Also note that one may find some topics unnecessary because the performance gain is minimal. Still I think it's good to list those topics, even if it's only for a better insight.
>Info: I urge other authors not to edit this
cookbookwiki, but of course anyone can make suggestions in the comments section or drop me a private message in forum. Thanks!
# Table Of Contents #
- __`1. MySQL`__
- `Setting The Best Suited Charset`
- `Working With IP Addresses`
- __`2. PHP`__
- `The Type-Safe Operator`
- __`3. Yii Framework / Applications`__
## 1. MySQL #
#
>Info: Some overview description soon...
##
# Setting The Best Suited Charset ##
#
When working with UTF-8 charsets (or multibyte charsets in general), it's good practise to set the proper collation charset for each database table.[...]
A real performance boost will show up with a lot of entries in a table. Still there's no argument not to do it for small tables also.
### Working With IP Addresses ##
#
Most PHP applications I've seen save ip addresses as a `string` of column type `VARCHAR(15)`. This works well and is already fast when used with an index. Still there is a much better solution.[...]
So when saving ip addresses as numerical values, you have the benefit of faster selections/sorting and the size of the table will be smaller since `INT(10)` consumes 4 bytes whereas `VARCHAR(15)` consumes at least 16 bytes or more (depends on the used charset).
Note that this only works with ipv4 addresses.
## 2. PHP #
#
>Info: Some overview description soon...
##
# The Type-Safe Operator ##
#
PHP has a loose typing system. That means when comparing values, each value can be of a different type.[...]
As you can see it's quite simple. If you use the type-safe operator extensively, you will have a small performance boost and your statements will be less error-prone since you always compare values of the same type. Also note that using the type-safe operator is always faster, even if you cast each value you want to compare to a specific type.
## 3. Yii Framework / Applications #
#
>Info: Soon