【发布时间】:2011-11-24 12:15:57
【问题描述】:
我使用 MySQL (MyISA)。超过 8M 行的表。 'id' 上的主索引。
我的申请展示:
first run: 55 req/sec,
second run: ~120 req/sec,
third run: ~1200 req/sec,
fourth run: ~4500 req/sec,
fifth run: ~9999 req/sec
重启 mysql-server 后再次相同。 启动数据库服务器后如何将所有索引一次性放入内存?
在我的.cnf 中
key_buffer_size=2000M
代码示例:
now = datetime.datetime.now()
cursor = connection.cursor()
for x in xrange(1, 10000):
id = random.randint(10, 100000) # random first 10000 records for cache
cursor.execute("""SELECT num, manufacturer_id
FROM product WHERE id=%s LIMIT 1""", [id])
cursor.fetchone()
td = datetime.datetime.now() - now
sec = td.seconds + td.days * 24 * 3600
print "%.2f operation/sec" % (float(x) / float(sec))
【问题讨论】: