Re: [BUGS] BUG #11500: PRIMARY KEY index not being used
От | Wyatt Alt |
---|---|
Тема | Re: [BUGS] BUG #11500: PRIMARY KEY index not being used |
Дата | |
Msg-id | CAGem3qDgH3TQPMHvQD92GOnDmL9mbTGZVTm1eQVsmr8CkfhHew@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [BUGS] BUG #11500: PRIMARY KEY index not being used (David Rowley <dgrowleyml@gmail.com>) |
Список | pgsql-bugs |
On Fri, Oct 3, 2025 at 8:19 PM David Rowley <dgrowleyml@gmail.com> wrote:
I can't off the top of my head think of a way to
do that with an enum column.
Casting the enum to text seems to work:
EXPLAIN SELECT 1 FROM orders WHERE order_id = 1 AND state = 'WAIT_EVENT';
QUERY PLAN
------------------------------------------------------------------------------------
Index Scan using orders_wait_event_idx on orders (cost=0.12..2.34 rows=1 width=4)
Filter: (order_id = 1)
(2 rows)
EXPLAIN SELECT 1 FROM orders WHERE order_id = 1 AND state::text = 'WAIT_EVENT';
QUERY PLAN
--------------------------------------------------------------------------
Index Scan using orders_pkey on orders (cost=0.42..2.65 rows=1 width=4)
Index Cond: (order_id = 1)
Filter: ((state)::text = 'WAIT_EVENT'::text)
(3 rows)
QUERY PLAN
------------------------------------------------------------------------------------
Index Scan using orders_wait_event_idx on orders (cost=0.12..2.34 rows=1 width=4)
Filter: (order_id = 1)
(2 rows)
EXPLAIN SELECT 1 FROM orders WHERE order_id = 1 AND state::text = 'WAIT_EVENT';
QUERY PLAN
--------------------------------------------------------------------------
Index Scan using orders_pkey on orders (cost=0.42..2.65 rows=1 width=4)
Index Cond: (order_id = 1)
Filter: ((state)::text = 'WAIT_EVENT'::text)
(3 rows)
В списке pgsql-bugs по дате отправления: