DB設計時のサイズ見積もり

ここのところ、javaccawsに魅了されている米林です。

よく使うDB(Oracle/MySQL/PostgreSQL/SQLServer)における設計時のサイズ見積もりで使うサイトの備忘録。
あとは、OracleからのPython情報。

Oracle

領域サイズ見積もり

http://otn.oracle.co.jp/document/estimate/index.html

OTNにログインする必要ありますがオンラインで見積もりが出来ます。
アカウント持っていない人は、この見積もりツールを使う目的でアカウントを作ってみてはいかがでしょうか。

OLTP系とDWH系においてブロックサイズを考慮し、DWH系はブロックサイズを大きくする事を知りませんでした。


MySQL5.1

データタイプが必要とする記憶容量

http://dev.mysql.com/doc/refman/5.1/ja/storage-requirements.html

InnoDB ファイル領域の管理とディスク I/O

http://dev.mysql.com/doc/refman/5.1/ja/file-space-management.html


SQLServer

データベース サイズの見積もり

http://msdn.microsoft.com/ja-jp/library/ms187445.aspx

テーブル サイズの見積もり

http://msdn.microsoft.com/ja-jp/library/ms175991.aspx

ヒープ サイズの見積もり

http://msdn.microsoft.com/ja-jp/library/ms189124.aspx

クラスタ化インデックスのサイズの見積もり

http://msdn.microsoft.com/ja-jp/library/ms178085.aspx

PostgreSQL

テーブルの構造とディスク容量の見積もり(WEB+DB Pressの記事)

http://www2b.biglobe.ne.jp/~caco/webdb-pdfs/vol24_214-221.pdf

ディスク使用量の決定

http://www.postgresql.jp/document/pg837doc/html/disk-usage.html


個人的には、MySQLよりPostgreSQLが好きです。


Oracle以外でもオンラインで見積もり出来るところあれば良いのに。

Adding a Python Twist

DB設計とは関係無いのですが、GWにOracle's Dev2DBA Newsletterが届いて件名が "Adding a Python Twist" との事で見てみました。見ておいて損は無いのでついでに紹介します。

Tech Article: Python Data Persistence with Oracle Database

http://www.oracle.com/technology/pub/articles/vasiliev-python-persistence.html?msgid=7615911

いつぞや、mopemopeが紹介してたcx_Oracleでapache2.x, Oracle, Python, mod_pythonの構成で
PSPを使ったサンプルアプリを作りながら説明してます。

あとは

High Concurrency with Python and Oracle Database

http://www.oracle.com/technology/pub/articles/vasiliev-python-concurrency.html?msgid=7615911


こちらの記事ではmutexが出てきてますよ。
Synchronizing Access to Shared Resources

import sys
import cx_Oracle
import threading
from xml.dom.minidom import parseString
from urllib import urlopen

#subclass of threading.Thread
class SynchThread(threading.Thread):
   def __init__(self, cur, query, dom):
     threading.Thread.__init__(self)
     self.cur = cur
     self.query = query[1]
     self.tag = query[0]
     self.dom = dom
   def run(self):
     self.cur.execute(self.query)
     rslt = self.cur.fetchone()[0]
     self.cur.close()
     mutex.acquire()
     sal = self.dom.getElementsByTagName('salary')[0]
     newtag = self.dom.createElement(self.tag)
     newtext = self.dom.createTextNode('%s'%rslt)
     newtag.appendChild(newtext)
     sal.appendChild(newtag)
     mutex.release()
#main thread starts here
domdoc = parseString('')
dbconn = cx_Oracle.connect('hr', 'hr', '127.0.0.1/XE',threaded=True)
mutex = threading.Lock()
queries = {}
queries['avg'] = "SELECT AVG(salary) FROM employees"
queries['max'] = "SELECT MAX(salary) FROM employees"
th = []
for i, query in enumerate(queries.items()):
   cur = dbconn.cursor()
   th.append(SynchThread(cur, query, domdoc))
   th[i].start()
#forcing the main thread to wait until all child threads are done
for t in th:
   t.join()
#printing out the result xml document
domdoc.writexml(sys.stdout)
Using Twisted, Python Event-Driven Framework

これもmopemopeがよく使ってるTwistedですね、Oracleよりもmopemopeは先行ってるのでしょうか。

from twisted.internet import reactor
from twisted.enterprise import adbapi

def printResult(rslt):
   print rslt[0][0]
   reactor.stop()

if __name__ == "__main__":
   dbpool = adbapi.ConnectionPool('cx_Oracle', user='hr', password ='hr', dsn='127.0.0.1/XE')
   empno = 100
   deferred = dbpool.runQuery("SELECT last_name FROM employees WHERE employee_id = :empno", {'empno':empno})
   deferred.addCallback(printResult)
   reactor.run()


Oracleさん、素敵な情報ありがとうございます!