当前位置:网站首页>postgresql 范围查询比索引查询快吗?
postgresql 范围查询比索引查询快吗?
2022-07-31 08:59:00 【MonkeyKing_sunyuhua】
EXPLAIN ANALYZE select
*
from
billing_detail as billingDetail
where
billingDetail.start_time >= '2022-06-01 00:00:00'
and billingDetail.end_time <= '2022-07-01 00:00:00'
--billing_cycle='2022-06'
--and billingDetail.id is not null
and billingDetail.tenant_id = 0
and billingDetail.billing_type in('OD',null)

EXPLAIN ANALYZE select
*
from
billing_detail as billingDetail
where
--billingDetail.start_time >= '2022-06-01 00:00:00'
--and billingDetail.end_time <= '2022-07-01 00:00:00'
billing_cycle='2022-06'
--and billingDetail.id is not null
and billingDetail.tenant_id = 0
and billingDetail.billing_type in('OD',null)

表中共有126万行数据,表的数据的索引创建:
验证下来的确范围查询更快一些。很奇怪
再次添加104万行数据,时间格式不重复,随机生成的值,区分度很大,之前的126行区分度底
数据如图所示:
再次进行比较:




再次比较:还是发现范围查询比直接走索引还是快一些。
这里postgresql对范围查询做了优化,但是具体怎么做优化的还需要继续学习调研一下,
有已经参透的同学,可以留言回复。
边栏推荐
- 奉劝那些刚参加工作的学弟学妹们:要想进大厂,这些核心技能是你必须要掌握的!完整学习路线!
- SQL语句知识大全
- 状态机动态规划之股票问题总结
- Docker-compose安装mysql
- Small application project development, jingdong mall 】 【 uni - app custom search component (below) - search history
- 搭建frp进行内网穿透
- torch分布式训练
- Job hunting product manager [9] How to write a good resume in job hunting season?
- How on one machine (Windows) to install two MYSQL database
- 优信年营收16亿:亏损3亿 已与蔚来资本及58集团签署股权协议
猜你喜欢

Splunk Workflow action 给我们带来的好处

【插值与拟合】

SSM framework explanation (the most detailed article in history)

Vue项目通过node连接MySQL数据库并实现增删改查操作

SSM框架简单介绍

Spark 在 Yarn 上运行 Spark 应用程序
![[MySQL exercises] Chapter 2 Basic operations of databases and data tables](/img/43/73a59a293d4708b6f9aeae990a7029.png)
[MySQL exercises] Chapter 2 Basic operations of databases and data tables

文件管理:目录管理

0730~Mysql optimization

【小程序项目开发--京东商城】uni-app之自定义搜索组件(上)-- 组件UI
随机推荐
【RISC-V】risc-v架构学习笔记(架构初学)
【Unity】编辑器扩展-01-拓展Project视图
优信年营收16亿:亏损3亿 已与蔚来资本及58集团签署股权协议
@RequestBody和@RequestParam区别
Doraemon teach you forwarded and redirect page
mysql 数据去重的三种方式[实战]
安装sambe
【小程序项目开发-- 京东商城】uni-app之商品列表页面 (上)
Flutter Paystack 所有选项实现
状态机动态规划之股票问题总结
SQL 入门之第一讲——MySQL 8.0.29安装教程(windows 64位)
Hematemesis summarizes thirteen experiences to help you create more suitable MySQL indexes
科目三:左转弯
MUI获取相机权限
SSM框架讲解(史上最详细的文章)
MySQL 数据库基础知识(系统化一篇入门)
How to Install MySQL on Linux
7. JS ES6新增语法 new Map详讲,还有一道代码实战案例帮你快上手new Map
Flutter Paystack implements all options
02 Truffle TutorialToken 示例