2010-06-22

[ubuntu] dist-upgrade - 使用 apt 指令更新核心

軟體更新
apt-get upgrade 


核心更新

sudo apt-get dist-upgrade

2010-06-09

PHP function: 壓縮 CSS file

<?php
/**
 * Converts a CSS-file contents into one string
 * Source Code: http://snippets.dzone.com/posts/show/4137
 * @Author: Dmitry-Sh http://snippets.dzone.com/user/Dmitry-Sh
 *
 * @param    string  $t Text data
 * @param    int     $is_debug Skip convertion
 * @return   string  Optimized string
 *

/

2010-06-03

MySQL: UNION和UNION ALL

在資料庫中,UNIONUNION ALL關鍵字都是將兩個結果集合並為一個,但這兩者從使用和效率上來說都有所不同。
MySQL中的UNION
UNION在進行錶鏈接後會篩選掉重複的記錄,所以在錶鏈接後會對所產生的結果集進行排序運算,刪除重複的記錄再返回結果。實際大部分應用中是不會產生重複的記錄,最常見的是過程表與歷史表UNION。如:
select * from users1 union select * from user2
這個SQL在運行時先取出兩個表的結果,再用排序空間進行排序刪除重複的記錄,最後返回結果集,如果表資料量大的話可能會導致用磁片進行排序。
MySQL 中的UNION ALL
UNION ALL只是簡單的將兩個結果合併後就返回。這樣,如果返回的兩個結果集中有重複的資料,那麼返回的結果集就會包含重複的資料了。
從效率上說,UNION ALL 要比UNION快很多,所以,如果可以確認合併的兩個結果集中不包含重複的資料的話,那麼就使用UNION ALL,如下:
select * from user1 union all select * from user2