SQL

楼主: sustainer123 (caster)   2024-08-02 22:53:33
每日提交不了 先写这个
今天有点忙 没看多少 姆咪
b-tree index with hash
就原本index 但变量加个hash function
像是md5
大小会减少很多
假如先建立md5的字段 uuid
然后把存入的资料加上hash function
放进uuid 这样空间跟时间都是最好的
b-tree Index跟 hash index的适用范围
b-tree
前缀 比大小 特定范围 排序 精确搜寻
这边其实我不太懂
b-tree适用范围那么大
为啥昨天有些还是 sqe scan
感觉这边可以仔细研究 姆咪
hash
精确搜寻
hash index
create unique index cr2_md5 on cr2(md5(url))
这会是包著hash 内容物的 btree
create index cr4_hash on cr4 using hash(url)
要特别指定才会用hash index
好处:更省空间
理论上hash查询速率应该>tree才对
但postgresql却反过来
可能优化差别吧
要查一下
作者: SecondRun (雨夜琴声)   2024-08-02 22:58:00
大师
楼主: sustainer123 (caster)   2024-08-02 23:01:00
我上次数据库被问倒才开始恶补 哭了

Links booklink

Contact Us: admin [ a t ] ucptt.com