我有一个具有以下架构的 postgres 表
Table "public.myTable"
Column | Type | Modifiers
----------- +--------------------------+-----------
serial_number | character varying(255) |
name | character varying(255) |
Designation | character varying(255) |
place | character varying(255) |
timeOfJoining | timestamp with time zone |
timeOfLeaving | timestamp with time zone |
Indexes:
"name_Designation_place" btree (name, Designation, place)
"Designation_place_name" btree (Designation, place, name)
"Designation_name_place" btree (Designation, name, place)
"timeOfJoining_timeOfLeaving" btree (timeOfJoining, timeOfLeaving)
"timeOfJoining_timeOfLeaving" btree (timeOfJoining, timeOfLeaving)
现在,当我运行表单查询时:
explain analyze select place from myTable where Designation='Manager' and timeOfJoining>'1930-10-10';
我得到以下计划:
Index Scan using Designation_place_name on myTable (cost=0.00..67701.36 rows=22043 width=27) (actual time=0.061..3.796 rows=3376 loops=1)
Index Cond: ((relation)::text = 'Manager'::text)
Filter: (timeOfJoining > '1930-10-10 00:00:00+05:53:20'::timestamp with time zone)
Total runtime: 4.082 ms
(4 rows)
现在我无法理解查询计划是如何执行的。查询计划是否首先从 myTable 上的索引 Designation_place_name 检索序列号,然后转到 myTable 并获取行,然后在 timeOfJoining 上执行过滤
或者
查询计划是否同时获取索引 timeOfJoining_timeOfLeaving 和 Designation_place_name 然后执行连接,并且在此连接时完成过滤?