Warum bekomme ich Seq scan
, wenn ich den Teilindex in \d+
Befehle sehen kann;Teilindizierung nicht wirksam
\d+ call_records;
id | integer | not null default nextval('call_records_id_seq'::regclass) | plain | |
plain_crn | bigint |
active | boolean | default true
timestamp | bigint | default 0
Indexes:
"index_call_records_on_plain_crn" UNIQUE, btree (plain_crn)
"index_call_records_on_active" btree (active) WHERE active = true
Was id
erwartet war ein Index Scan.
EXPLAIN select * from call_records where id=1;
QUERY PLAN
----------------------------------------------------------------------------------------
Index Scan using call_records_pkey on call_records (cost=0.14..8.16 rows=1 width=373)
Index Cond: (id = 1)
(2 rows)
Das Gleiche gilt für plain_crn
EXPLAIN select * from call_records where plain_crn=1;
QUERY PLAN
------------------------------------------------------------------------------------------------------
Index Scan using index_call_records_on_plain_crn on call_records (cost=0.14..8.16 rows=1 width=373)
Index Cond: (plain_crn = 1)
(2 rows)
Aber, es ist nicht das gleiche bei active
.
EXPLAIN select * from call_records where active=true; QUERY PLAN
-----------------------------------------------------------------
Seq Scan on call_records (cost=0.00..12.00 rows=100 width=373)
Filter: active
(2 rows)
Bitte senden Sie die Ausgabe von 'erklären (analysieren, ausführlich)' für alle Abfragen –