2013年2月26日 星期二

[SQL]反向查詢吃不到INDEX

剛剛在看文件的時候看到
select 的條件若有 <> 時會吃不到Index

另外也儘量不用 not in
可以用not exists or in ( select ... from table1 minus select ... from table2)

以上可以提升效能

http://stackoverflow.com/questions/3545323/why-the-select-from-table-where-id-not-in-list-of-int-ids-query-is-slow-in

2013年2月22日 星期五

[SQL]optimal not in performance

若使用not in 的效能很差
可以改用minus可以提升效能

http://dbaforums.org/oracle/index.php?showtopic=21583
http://www.dba-oracle.com/oracle_news/2005_3_31_tips_using_not_exists_minus_sql.htm
http://www.dba-oracle.com/t_cbo_existence_queries.htm

2013年2月14日 星期四

[SQL] new line sign


new line in plsql is  CHR(13) || CHR(10)



reference:http://www.orafaq.com/forum/t/59679/2/

2013年2月4日 星期一

[SQL]ROW LOCK的發生情況



1.UPDATE的時候會造成ROW LOCK

最好在UPDATE後COMMIT
開頭也要加 PRAGMA AUTONOMOUS_TRANSACTION

2.同時INSERT時也會LOCK

參考:
http://www.dbasky.com/oracle/update_index_row_lock_waits.html