Btree 의 속도를 향상시키는 방법 ?

kicom95의 이미지

안녕하세요

버클리 DB 아시죠 ? 전 이넘을 사용해서 프로그램을 개발중에 있습니다.

수십 만개의 키 까지는 별 속도의 문제가 없었으나

잦은 데이터 삽입과... 값의 변경이 내부 파일의 변화를 가져와서..

상당히 속도가 느려지고 있습니다. -_- ( 1G 정도 되거든요 )

( 현재는 저만 이사실을 아는데 쩝 )

버클리 DB 말고 다른 B Tree 라이브러리에 대해서 아시면

조언 부탁 드리지요 ^^

아니면 버클리의 성능 향상 방법 이라던지

미리 감사드립니다 ^^

kicom95의 이미지

답변이 없으셔서 좀더 구체적으로 적어 봅니다.

제가 지금 버클리 DB 에 데이터를 집어 넣는 것은

크기가 고정적입니다 다시 말해 key 와 data 의 크기가 고정적이라는 것이지요

그리고 insert 한후에 빈번하게 data 에는 수정이 되는데요...

처음에 데이터를 집어 넣는 경우나 data 를 수정하는 경우에는 속도의

변화가 별로 없지만.... 차차 데이터를 많이 넣을 수록 급격히 속도가 많이

떨어집니다 T.T

Btree 로 구현된거 중에 삽입,삭제 정도만 구현된거면 되는데 ^^;;

좋은 소스 있으면 말씀 해주세요. 참조하게요

가자 해외로 ~ .. 돈 벌러.

소타의 이미지

sqlite 에 btree 관련된 모듈이 있습니다.
http://www.sqlite.org/
btree를 고집하시는 걸 보니 순차검색이나 정렬이 이루어 져야만 하는 건가용? 아니면 다른 더 좋은 방법도 있을듯 합니다..
=3=3

cinsk의 이미지

아래 싸이트에서 Getting Started .. C 문서를 보시기 바랍니다.

http://www.sleepycat.com/supports/documentation.shtml

여기에 보면 DB가 커질 때에는 DB type을 BTree보다 Hash를 쓸 것을 권장하고 있습니다:

Quote:

Choosing between BTree and Hash For small working datasets that fit entirely in memory, there is no difference between BTree and Hash. Both will perform just as well as the other. In this situation, you might just as well use BTree, if for no other reason than the majority of DB applications use BTree.

Note that the main concern here is your working dataset, not your entire dataset. Many applications maintain large amounts of information but only need to access some small portion of that data with any frequency. So what you want to consider is the data that you will routinely use, not the sum total of all the data managed by your application.

However, as your working dataset grows to the point where you cannot fit it all into memory, then you need to take more care when choosing your access method. Specifically, choose:

* BTree if your keys have some locality of reference. That is, if they sort well and you can expect that a query for a given key will likely be followed by a query for one of its neighbors.

* Hash if your dataset is extremely large. For any given access method, DB must maintain a certain amount of internal information. However, the amount of information that DB must maintain for BTree is much greater than for Hash. The result is that as your dataset grows, this internal information can dominate the cache to the point where there is relatively little space left for application data. As a result, BTree can be forced to perform disk I/O much more frequently than would Hash given the same amount of data.

Moreover, if your dataset becomes so large that DB will almost certainly have to perform disk I/O to satisfy a random request, then Hash will definitely out perform BTree because it has fewer internal records to search through than does BTree.

cinsk의 이미지

아울러, 위에서 보인 문서에 보시면 DB의 성능을 좋게 할 수 있는 여러 방법이 나와 있습니다.

먼저, secondary database를 보시고, 그 다음 cache size를 조정하는 단락을 읽어 보시기 바랍니다.

kicom95의 이미지

Hash 는 우선 생각의 대상이 아니에요 -_-

속도를 위해서는 이 방법이 최고 입니다.

우선 캐시 크기를 좀 많이 늘리는게 좋은 방법 같습니다.

Quote:

increasing the size of the cache until the hit rate reaches 100% or levels off will yield the best performance ....

db_stat 를 통하면 최적의 캐시 사이즈를 알수 있다는데...

사정상 구버젼을 써야 하므로... 잘 체크가 안되지만....

야튼 답변 감사 드립니다.

오늘 오전에 GTK 의 Btree 부분을 뜯어 볼려구 했는데...

sqllite 도 한번 고려 해봐야 겟습니다.

^^

참 secondary database 이는 보이지 않던데요 ^^

Secondary indices 를 말씀하시는 거지요 ?

가자 해외로 ~ .. 돈 벌러.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.