2008年6月17日 星期二

倒數....

再55天,你就要搭上飛機,去下一趟旅程,

我不在時,記得要好好吃飯

我不在時,記得要好好睡覺

沒有人會接送,回家要注意

吃東西要小心,不要過敏了變成鹹蛋超人(龍蝦)

 

三年好像很長又好像很短

在你啟程前,很想再把我們去過的地方再去一次

但是我們去過的地方太多,55天是去不完的,你說對吧

南投的超大溫泉很好玩

綠島雖然下雨,但是浮浮很特別

宜蘭的玻璃海岸垃圾真多,不過沙裡有玻璃很漂亮

Helen來台灣的旅程,不知道你開不開心呢?

還有動物園、雙魚花園、士林夜市、台南貓展、大湖草莓、清境農場、向陽農場、瑪利亞義大利麵、嘉義鹽田、聖誕節波波大餐、小碧潭夜遊、石碇豆花、深坑豆腐、瑪麗葉的生日蛋糕、六福村、宜蘭童玩節、傳統藝術博物館、明日博物館、8K三明治、傷心咖啡店、平溪十分遊、陳綺貞華麗的冒險 淡水動物園 a Piece of summer、金山鴨肉、海水浴場、大溪漁港的海膽、緣道觀音寺、鶯歌、台北無車日、過年彰化遊、蜜餞形象館、關西的野薑花粽、海洋深呼吸的焗烤、無數次的寵物展跟台南的貓展、紙片馬力歐、銀河馬力歐.....還有很多很多......

 

應該只有我們會在寒流來的時候,在海邊跟美術公園逛半天,

冷的發抖都沒說出真心話

應該只有你會把看IMAX當作去要去看摩天輪,心裡還暗暗的想這個人真奇怪

應該也只有你會把如果沒有帶到堤防作遛貓活動,把貓掛著走來走去,

被貓抓傷還玩得很開心

 

去了就要加油.....我會教沒有游泳 好游去陪你的

時候到了要分離時 記得一定要好好照顧自己....

我會賺大$ 再去陪妳的喔(沒賺到就沒辦法了....)

2008年6月3日 星期二

Char 轉成 TCHAR的辦法

// ANSI(char) to Unicode(TCHAR)
char* temp = "測試";
int nIndex = MultiByteToWideChar(CP_ACP, 0, temp , -1, NULL, 0);
TCHAR *pUnicode = new TCHAR[nIndex + 1];
MultiByteToWideChar(CP_ACP, 0, temp , -1, pUnicode, nIndex);


// Unicode(WCHAR) to ANSI(char)
TCHAR *pUnicode = _T("你好");
int nIndex = WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, NULL, 0, NULL, NULL);
char *temp = new char[nIndex + 1];
WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, temp , nIndex, NULL, NULL);
delete pAnsi;

2008年6月1日 星期日

SQL Paging 的效率

T-SQL:

SET STATISTICS io ON
SET STATISTICS time ON
go
Select * FROM   (Select   Top 40000   *   from   core_users ) A  where Not   Exists
( Select * From (Select   top 20000  userid   from   core_users ) B where A.userid=B.userid )
go
SET STATISTICS profile OFF
SET STATISTICS io OFF
SET STATISTICS time OFF
SET STATISTICS io ON
SET STATISTICS time ON
go
SELECT *
FROM (
SELECT *,ROW_NUMBER() OVER (ORDER BY UserId DESC) AS RowNumber
FROM Core_users ) T
WHERE T.RowNumber BETWEEN 20000 AND 40000
SET STATISTICS profile OFF
SET STATISTICS io OFF
SET STATISTICS time OFF

 

 

Result:

SQL Server parse and compile time:
   CPU time = 30 ms, elapsed time = 33 ms.

(10611 row(s) affected)
Table 'Core_Users'. Scan count 2, logical reads 2654, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
   CPU time = 681 ms,  elapsed time = 3537 ms.
SQL Server parse and compile time:
   CPU time = 0 ms, elapsed time = 1 ms.

SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 1 ms.

SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 1 ms.
SQL Server parse and compile time:
   CPU time = 30 ms, elapsed time = 32 ms.

 

(10612 row(s) affected)
Table 'Core_Users'. Scan count 1, logical reads 1574, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
   CPU time = 601 ms,  elapsed time = 4101 ms.

SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 1 ms.

SQL Server Execution Times:
   CPU time = 0 ms,  elapsed time = 1 ms.

Difference between "Not in" and "Not Exist" In SQL

1.如果要查詢的列上沒有NULL值,NOT   IN   和   NOT   Exist效率是一樣的.

2.當資料量較少時,not   in執行速度比not   exists快,反之,not   exists較可取
3.同樣,處理   IN   和Exist   也有下面的規則:

  1. 內查詢為小表,外查詢為大表時,使用IN的效率高
  2. 內查詢為大表,外查詢為小表時,使用Exist的效率高.

例:

select   count(*)   from   bigtable   where   id   in(select   id   from   smalltable)  
效率高
select   count(*) from bigtable where exists ( select null from   smalltable where  smalltable.id=bigtable.id   )  
效率低

select   count(*)   from   smalltable  where   id   in   (select   id   from   bigtable)  
效率差一點
select   count(*)     from   smalltable where   exists   (   select   null   from   bigtable where   smalltable.id   =   bigtable.id   )  
效率好一點.