Re: Why is this query running slowly?

Поиск
Список
Период
Сортировка
От John R Pierce
Тема Re: Why is this query running slowly?
Дата
Msg-id 4E71B3EC.9080701@hogranch.com
обсуждение исходный текст
Ответ на Why is this query running slowly?  (Yang Zhang <yanghatespam@gmail.com>)
Список pgsql-general
On 09/15/11 12:53 AM, Yang Zhang wrote:
> mydb=# explain select user_id from den where user_id not in (select
> duid from user_mappings) and timestamp between '2009-04-01' and
> '2010-04-01';
>
>             QUERY PLAN
>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>   Seq Scan on den  (cost=711.58..66062724212.74 rows=22634720 width=4)
>     Filter: (("timestamp">= '2009-04-01 00:00:00'::timestamp without
> time zone) AND ("timestamp"<= '2010-04-01 00:00:00'::timestamp
> without time zone) AND (NOT (SubPlan 1)))
>     SubPlan 1
>       ->   Materialize  (cost=711.58..1223.38 rows=36780 width=4)
>             ->   Seq Scan on user_mappings  (cost=0.00..530.80 rows=36780 width=4)
>
> user_mappings is fairly small:

so you have to check if every one of the 22 million rows of 'den' in
that time range and is not one of the 36000 rows of user_mappings?

how many rows are in that time range?

are timestamp and duid indexed?  have the tables been analyzed any time
recently?


--
john r pierce                            N 37, W 122
santa cruz ca                         mid-left coast


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

Предыдущее
От: Yang Zhang
Дата:
Сообщение: Re: Why is this query running slowly?
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: Problem with the 9.1 one-click installer Windows7 64bit