sqlite可以加载10M数据到内存吗 [英] can sqlite load 10M data into the memory

查看:23
本文介绍了sqlite可以加载10M数据到内存吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可能,怎么做?

我想加快 sqlite 中的阅读速度(而不是写作速度)

I want to speed up the readings (not writings) in sqlite

谢谢

推荐答案

是.

SQLite 以页面的形式将数据加载到内存中.默认页面大小为 1024 字节.您可以使用此命令更改页面大小.

SQLite loads data into memory in pages. The default page size is 1024 bytes. You can change the page size using this command.

PRAGMA page_size = bytes;

但是您必须在创建数据库之前执行此操作(或在 3.5.8 中,您可以在发出新的页面大小编译指示后通过运行 VACUUM 来更改它).

But you have to do this before you create the database (or in 3.5.8, you can change it by running a VACUUM after issuing the new page size pragma).

缓存基于页数.默认缓存大小为 2000 页.您可以使用此命令更改它.

The cache is based on number of pages. The default cache size is 2000 pages. You can change it using this command.

PRAGMA cache_size = Number-of-pages;

所以要在内存中存储 10MB 的数据,要么将页面大小增加到 5120,要么将缓存大小增加到 10000.

So to store 10MB of data in memory, either increase the page size to 5120 or increase the cache size to 10000.

有关编译指示的更多信息在这里.

More info on pragmas is here.

这篇关于sqlite可以加载10M数据到内存吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆