본문 바로가기

DB

mongodb 설치 빠르게 mongodb를 사용해보기 위해 window에 설치 해보았다. 설치는 mongodb home page에 설명이 쉽게 되어있다. 설치 다운로드링크이다. http://www.mongodb.org/downloads 나는 Windows 64-bit를 사용하고 있고 Win7을 사용중이기 때문에 windows server 2008이나 Windows 7에서 더 좋은 성능을 보인다는 64bit 2008+ 빌드를 다운로드 했다. 압축을 풀면 처럼 여러개의 실행 파일들이 생긴 것을 볼 수 있다. 압축해제 후 bin 폴더의 모습 저기서 mongod는 mongo db서버 daemon이고 mongo는 client 프로그램이다. 재미있는 것은 client interface가 javascript라는 것이다. 그 다음에는 아.. 더보기
Mysql purge lag Mysql을 사용하면서 대량을 삭제가 발생할 때 purge lag이 싸여서 mysql 응답속도가 느려질 수 있다는 이야기를 들은 적이있다. 괜찮은 페이지를 찾아서 정리해 놓는다. http://mysqlha.blogspot.com/2008/07/how-do-you-know-when-innodb-gets-behind.html InnoDB does not remove deleted rows from a table until they cannot be read by any other transaction. This is done by a background thread. Deleted rows that have not been purged artificially increase the size of a tabl.. 더보기
mysql replication 문제 (update replication 실패) 며칠전에 mysql master장비에 update를 했는데 replica(slave) 장비에는 update되지 않는 현상을 발견했다. slave 장비의 Seconds_Behind_Master도 0이었다. 즉, update량이 많아서 늦어지는 것이 아니었다는 이야기다. 나는 그 row들에 다시한번 update를 하다가 이상한 점을 발견했는데 실제로 update되지 않는 것을 목격한 것이다. 즉, master에 update MyDatabase.MyTable set myname="jigu" where id=12345; 라는 query를 쳤을 때 mater 장비의 myname에는 "jigu"가 slave의 myname에는 "abc"라는 이전값이 그대로 있는 것이다. 원인은 database name을 주는 방식에.. 더보기
Mysql timestamp update null value, mysql에서 timestamp 컬럼에 null을 update할때 Mysql에서 자주 사용하는 TimeStamp는 날짜, 혹은 시간을 나타내는 컬럼이다. Mysql의 Tiemstamp관련 문서다. http://dev.mysql.com/doc/refman/5.0/en/timestamp.html TIMESTAMP columns are NOT NULL by default, cannot contain NULL values, and assigning NULL assigns the current timestamp. However, a TIMESTAMP column can be permitted to contain NULL by declaring it with the NULL attribute. In this case, the default value also becomes NUL.. 더보기
Mysql 서브쿼리 사용법 페이지 http://dev.mysql.com/tech-resources/articles/subqueries_part_1.html 아래와 같이 select 한 값을 where절 조건에서 사용할 때 SELECT name, headofstate, population FROM Country WHERE population=(SELECT MAX(population) FROM Country); 혹은 select 한 결과로 부터 다른 결과를 얻고자 할 때 사용한다. SELECT MAX(tbl.nr) AS nr FROM ( /* 2 */ SELECT countrycode, COUNT(*) AS nr FROM CountryLanguage WHERE isofficial='T' GROUP BY countrycode ) AS tbl; 더보기
Mysql index에 대해서 mysql이 index를 어떻게 사용하는지 설명한다. 나중에 보고 자세히 정리해보쟈 How MySQL Uses Indexes http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html 그리고 아래에서 보면 mysql에서 어떤 인덱스를 사용하면 좋을지 힌트를 줄 수 있는데 http://dev.mysql.com/doc/refman/5.1/en/index-hints.html 힌트는 세가지가 있다. index_hint: USE {INDEX|KEY} [{FOR {JOIN|ORDER BY|GROUP BY}] ([index_list]) | IGNORE {INDEX|KEY} [{FOR {JOIN|ORDER BY|GROUP BY}] (index_list) | FORCE {IN.. 더보기
mysql insert 속도에 대하여 (Speed of INSERT Statements) 다른 mysql에서 대량의 row를 insert하기위해서 insert의 capacity를 알아보려고 한다. mysql sql 사이트의 insert 속도에 대한 페이지이다. http://dev.mysql.com/doc/refman/5.0/en/insert-speed.html Connecting: (3) Sending query to server: (2) Parsing query: (2) Inserting row: (1 × size of row) Inserting indexes: (1 × number of indexes) Closing: (1) 위에서 괄호 안의 숫자는 차지하는 비율에 대한 숫자이다. 즉, Connection을 맺는 작업이 Closing하는 작업 보다 3배의 시간이 든다는 것이다. 결국, 넣.. 더보기
mysql md5 함수 사용 mysql에서 Text가 key가 되어야 할 경우 그에 대한 hash값을 사용하면 fixed_length로 key를 지정할 수 있다. 아래는 mysql의 암호화와 압축 관련함수 페이지이다. http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html MD5() Calculate MD5 checksum OLD_PASSWORD() Return the value of the pre-4.1 implementation of PASSWORD PASSWORD() Calculate and return a password string SHA1(), SHA() Calculate an SHA-1 160-bit checksum SHA2() Calculate an SHA-.. 더보기
mysql query browser 요즘 mysql workbench 보다 예전 gui tool이 더 쓰기 편한 것 같다;; http://dev.mysql.com/downloads/gui-tools/5.0.html 링크를 겨우 찾았네 ㅎ 더보기