简体   繁体   English

SQLite:查询分区表

[英]SQLite: querying partitioned tables

I have 100 tables with >1M records in each. 我有100个表,每个表中的记录都超过1M。 All tables differ by names but have identical structure: 所有表的名称不同,但结构相同:

 (valueX INT NOT NULL, valueY INT NOY NULL, valueZ INT NOT NULL).

All table names are listed in separate table NAMES(name TEXT NOT NULL) but due to SQLite limitations table name cannot be substituted in query as a variable. 所有表名都在单独的表NAMES(name TEXT NOT NULL)中列出,但由于SQLite的限制,表名不能在查询中替换为变量。

I want to search in all tables rows where valueX > valueZ AND valueZ < valueY while skipping first N and retrieving next K rows. 我想在所有表中搜索valueX > valueZ AND valueZ < valueY行,同时跳过前N个并检索下K个行。

I prefer not to waste disk space and/or memory, since I believe they may be not enough. 我不希望浪费磁盘空间和/或内存,因为我认为它们可能还不够。 That's effectively eliminates the UNION option I guess. 我猜这实际上消除了UNION选项。

What can be done - considering the constraints? 可以做些什么-考虑约束条件?

PS. PS。 By "What can be done" I express my will to learn about proper strategy and to see a sample of relevant query. 通过“可以做什么”,我表示愿意学习适当的策略并查看相关查询的样本。

PPS. PPS。 Number of tables can change anytime. 表的数量可以随时更改。

如果可能的话,SQLite将进行子查询拼合 ,因此,将表与UNION ALL (最好在视图中)简单组合并对其进行查询不会对磁盘​​/内存造成任何影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM