Query not using index

Поиск
Список
Период
Сортировка
От ryan@paymentalliance.net
Тема Query not using index
Дата
Msg-id 3afa85e1.271675648@news.postgresql.org
обсуждение исходный текст
Ответы Re: Query not using index
Список pgsql-general
Here's the query:

SELECT
cart_row_id
FROM
pa_shopping_cart
WHERE
order_id = 20;

Here's the schema:

       Attribute       |           Type           |
Modifier

-----------------------+--------------------------+---------------------------------------------------------------------
 cart_row_id           | integer                  | not null default
 product_id            | integer                  | not null
 color                 | character varying(100)   |
 size                  | character varying(100)   |
 style                 | character varying(100)   |
 order_id              | integer                  | not null
 time_added            | timestamp with time zone |
 voided_date           | timestamp with time zone |
 voided_by             | integer                  |
 expired_date          | timestamp with time zone |
 item_state            | character varying(50)    | default
'in_basket'
 received_back_date    | timestamp with time zone |
 price_charged         | numeric(30,6)            |
 price_refunded        | numeric(30,6)            |
 shipping_charged      | numeric(30,6)            |
 shipping_refunded     | numeric(30,6)            |
 price_tax_charged     | numeric(30,6)            |
 price_tax_refunded    | numeric(30,6)            |
 shipping_tax_charged  | numeric(30,6)            |
 shipping_tax_refunded | numeric(30,6)            |
 price_name            | character varying(30)    |
 refund_id             | integer                  |
 cs_comments           | text                     |
 price                 | numeric(30,6)            |
 ship_group_id         | integer                  |
 ship_package_id       | integer                  |
 delivery_date         | date                     |
 sentiment             | text                     |
 vendor_id             | integer                  |
 linkshare_sent        | bit(1)                   |
 mapped_to_address     | character(1)             |
 product_name          | character varying(200)   |
Indices: delivery_date_pa_shopping_cart_,
         pa_cart_by_item_state,
         pa_cart_by_order,
         pa_cart_by_product,
         pa_cart_row_order,
         pa_item_map_to_addr,
         pa_shop_cart_prod_ord_idx,
         pa_shopping_cart_pkey,
         ship_package_id_pa_shopping_car,
         vendor_id_pa_shopping_cart_key

There is an index on:
just order_id
just order_id and cart_row_id
and a PK on cart row_id

I don't understand why it's not using one of these indexes!
Please post your responses to the group - my email is down.

Thanks for any help!

-r

В списке pgsql-general по дате отправления:

Предыдущее
От: Hunter Hillegas
Дата:
Сообщение: Re: my connections never die
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Query not using index