Search Postgresql Archives

Re: Why is this query running slowly?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux