You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
如德哥写的**PostgreSQL 一复合查询SQL优化例子 - (多个exists , 范围检索 , IN检索 , 模糊检索 组合)**这篇文章如果条件改成create table test(id int, c1 text, c2 date, c3 text);
select * from test
where
c1 in ('1','2','3')
and c2 between current_date-1 and current_date
oder by c2 desc limit 10;
这样的查询语句创建btree联合索引create index idx_c2_c1_test on test(c2,c1);
使用这个索引只会读取时间范围,而c1的过滤却要回表过滤,而Oracle是会在索引上全部过滤掉的,索引性能pg不如Oracle快。
使用gin索引好像速度也不是很快。
感谢能给出优化方法或思路,万分感谢。
The text was updated successfully, but these errors were encountered:
如德哥写的**PostgreSQL 一复合查询SQL优化例子 - (多个exists , 范围检索 , IN检索 , 模糊检索 组合)**这篇文章如果条件改成create table test(id int, c1 text, c2 date, c3 text);
select * from test
where
c1 in ('1','2','3')
and c2 between current_date-1 and current_date
oder by c2 desc limit 10;
这样的查询语句创建btree联合索引create index idx_c2_c1_test on test(c2,c1);
使用这个索引只会读取时间范围,而c1的过滤却要回表过滤,而Oracle是会在索引上全部过滤掉的,索引性能pg不如Oracle快。
使用gin索引好像速度也不是很快。
感谢能给出优化方法或思路,万分感谢。
The text was updated successfully, but these errors were encountered: