【发布时间】:2018-10-19 19:31:14
【问题描述】:
我的表 (user_tran) 有 3 个字段“user_id”、“transaction_id”、“time_stamp”
我在time_stamp 上散列索引user_id 和transaction_id(因为我需要进行完全匹配)和b+ 树索引
查询是
select user_id from user_tran where transaction_id = 1 and time_stamp > now() - 3 days;
select transaction_id from user_tran where user_id = 1 and time_stamp > now() - 3 days;
有谁知道这个查询的复杂性是什么?我知道如果我们只按哈希索引列进行过滤,它将是 o(1) 并且 b+ 树给出 o(lgn)。但是将它们组合在一起呢?
那会是o(lgn + 1)吗?
此外,该表将如何存储在引擎盖下。 DBMS 会同时维护 3 个索引(2 个 hash 和 1 个 b+ 树)吗?
谷歌搜索了一下,没有找到答案。
【问题讨论】:
标签: database postgresql indexing