这是我在这里的官方第一个问题; 我欢迎任何/所有批评我的帖子,以便我可以学习如何成为一个更好的SO公民.
我正在审查非关系型DBMS,用于存储潜在的大型电子邮件退出列表,使用各自的Python客户端库,倾向于使用MongoDB或RethinkDB.我的应用程序的痛点是批量插入性能,因此我设置了两个Python脚本,将批量为5,000的20,000条记录插入到MongoDB和RethinkDB集合中.
MongoDB python脚本mongo_insert_test.py:
NUM_LINES = 20000
BATCH_SIZE = 5000
def insert_records():
collection = mongo.recips
i = 0
batch_counter = 0
batch = []
while i <= NUM_LINES:
i += 1
recip = {
'address': "test%d@test%d.com" % (i, i)
}
if batch_counter <= BATCH_SIZE:
batch.append(recip)
batch_counter += 1
if (batch_counter == BATCH_SIZE) or i == NUM_LINES:
collection.insert(batch)
batch_counter = 0
batch = []
if __name__ == '__main__':
insert_records()
Run Code Online (Sandbox Code Playgroud)
几乎相同的RethinkDB python脚本rethink_insert_test.py:
NUM_LINES = 20000
BATCH_SIZE = 5000
def insert_records():
i …
Run Code Online (Sandbox Code Playgroud)