用于有效多参数搜索的数据结构

时间:2012-09-13 21:31:41

标签: sql data-structures

我有多维对象的集合(例如class Person = {age : int , height : int, weight : int etc...})。 我需要使用查询查询集合,其中某些维度已修复,其余维度未指定(例如getallPersonWith {age = c , height = a}getAllPersonWith {weigth = d} ...)

现在我有一个带有{age, Height,...}的多图(例如可以修复的所有尺寸) - > List : Person。要执行查询,我首先计算验证查询的密钥集,然后合并映射中的相应列表。 在查询速度方面有什么更好的吗?特别是有什么更接近按维度使用一个排序列表(我认为这是最快的解决方案,但管理太麻烦:))

为了清楚起见,我不是在寻找一个SQL查询。

1 个答案:

答案 0 :(得分:0)

你的意思是:

SELECT * FROM person p
WHERE gender = 'F'
  AND age >=18
  AND age < 30
  AND weight > 60 -- metric measures here !!
  AND weight < 70
  AND NOT EXISTS (
    SELECT * from couple c
    WHERE c.one = p.id OR c.two=p.id
    );

为什么你认为我使用SQL?