我使用MySQL(MyISA)。超过8M行的表。 'id'的主要索引。mysql push index into memory
我的应用表明:
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服务器再次同后。 启动数据库服务器后,如何将所有索引一次放入内存中?
在my.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))
请参阅http://openquery.com/blog/cache-preloading-mysqld-startup – nos