2018年8月22日 星期三

join 6個Table,QO(Query Optimizer)至少要分析720次

http://www.benjaminnevarez.com/2010/06/optimizing-join-orders/

join 3個Table,QO(Query Optimizer)至少要分析6次
join 6個Table,QO(Query Optimizer)至少要分析720次
正規化程度越高,join過多資料表容易發生查詢效能問題

https://www.udemy.com/sql-server-table-index/

2018年7月8日 星期日

DbSchema設計工具

1.可以離線編輯,新專案還沒有資料庫時可以用來設計資料庫,規劃完可以直接產生Script
2.DbSchema專案檔副檔名是dbs,就是xml,可以用Notepad++打開,也方便進版控,紀錄資料庫變更歷程
3.Schema也可以匯出成html
4.支援的資料庫種類非常多,詳見 https://www.dbschema.com/drivers.html
5.Windows程式執行檔已經使用install4j打包,不需要另外安裝Java
6.有免安裝版本,也有Mac和Linux版本

用AdventureWorks2017範例資料庫產生的html檔
https://1drv.ms/u/s!AmQ3SaTA10NQihO3rtLzfZxvEXnO

台灣 .NET 技術愛好者俱樂部
https://www.facebook.com/groups/DotNetUserGroupTaiwan/permalink/1901424886817287/

DbSchema官網
https://www.dbschema.com

DbSchema 20% Discount
https://www.colormango.com/product/dbschema_112104.html

2018年4月23日 星期一

驗證Partition Table是否改善記憶體快取使用

驗證結果的確是index和partition table都有節省記憶體快取
以後再研究index seek和index scan細部運作,和它還不太熟@@

最後解法還是把歷史資料拆成歷史檔,確認程式不會查太久的資料
用SqlAgent每月把歷史資料轉入歷史檔
但是建NonClustered Index也會有幫助,只是ldf會比較大
PK是交易日期+交易編號+序號
交易日期是會最常被搜尋的column,所以用它建NonClustered Index
這題應該用不到Partition Table

SQL筆記:Index Scan vs Index Seek
Sql Server中的表访问方式Table Scan, Index Scan, Index Seek
SQL Server中SCAN 和SEEK的区别
Buffer Management

2018年4月15日 星期日

動態磁碟轉換基本磁碟(Convert Dynamic Disk to Basic Disk)

舊硬碟是500GB,原本打算用Acronis的Clone Disk把磁碟複製到新的2TB硬碟
被動態磁碟搞了一下午@@ 
Acronis在動態磁碟無法用Clone Disk
只能用備份再還原
,但無法開機(no boot disk detected or the disk has failed)
DISKPART指令要先delete volume才能轉
,硬碟裡面有很多資料不能刪
最後用『分区助手』先把來源磁碟轉成基本磁碟(轉換只要幾秒)
終於順利使用
Acronis的Clone Disk完成

在ptt找到有人的分享
https://www.ptt.cc/bbs/Storage_Zone/M.1344084490.A.B8B.html 

AOMEI Partition AssistantAOMEI Backupper付費的專業版似乎也可以 
都是傲梅科技的產品分区助手』是免費的但只有簡體中文介面

備註:

EaseUS Partition Master專業版(付費)應該也可以沒試過

2018年1月4日 星期四

DBCC DROPCLEANBUFFERS

CHECKPOINT;
GO
DBCC DROPCLEANBUFFERS;
GO

https://technet.microsoft.com/en-us/library/ms187762(v=sql.110).aspx

Use DBCC DROPCLEANBUFFERS to test queries with a cold buffer cache without shutting down and restarting the server.
To drop clean buffers from the buffer pool, first use CHECKPOINT to produce a cold buffer cache. This forces all dirty pages for the current database to be written to disk and cleans the buffers. After you do this, you can issue DBCC DROPCLEANBUFFERS command to remove all buffers from the buffer pool.


ref:
關於清除 SQL Server 查詢快取的那些事
僅清除 Clean Buffer,Dirty Buffer無法被清除

[SQL Server]記憶體緩存資料寫入磁碟(一)首部曲

DBCC DROPCLEANBUFFERS and CHECKPOINT

p.s.
資料量大要使用partition table

2017年12月6日 星期三

Robocopy and a Few Examples

https://social.technet.microsoft.com/wiki/contents/articles/1073.robocopy-and-a-few-examples.aspx

利用robocopy複製資料夾結構(不複製檔案)

robocopy /zb /e /xf *

https://social.technet.microsoft.com/Forums/lync/en-US/0b3d3006-0e0f-4c95-9e2f-4c820832ebfa/using-robocopy-to-copy-folder-structure-only?forum=w7itprogeneral

/zb allows you access into the folders that you DON'T have permission to.  This will let you pull a complete folder structure even to the folders you haven't been granted permission to so that you don't have to mess with permissions to get this information.