Re: Query plan looks OK, but slow I/O - settings advice? - Mailing list pgsql-performance

From Gavin Sherry
Subject Re: Query plan looks OK, but slow I/O - settings advice?
Date
Msg-id Pine.LNX.4.58.0508191710450.31045@linuxworld.com.au
Whole thread Raw
In response to Query plan looks OK, but slow I/O - settings advice?  ("Roger Hand" <RHand@kailea.com>)
List pgsql-performance
The query plan does *not* look okay.

> electric=# EXPLAIN ANALYZE
> electric-# SELECT datavalue, logfielddatatype, timestamp FROM logdata_recent
> electric-# WHERE (logfielddatatype = 70 OR logfielddatatype = 71 OR logfielddatatype = 69)
> electric-# AND graphtargetlog = 1327
> electric-# AND timestamp >= 1123052400 AND timestamp <= 1123138800
> electric-# ORDER BY timestamp;
>
                                                                         QUERY PLAN 
> --------------------------------------------------
>  Sort  (cost=82.48..82.50 rows=6 width=14) (actual time=60208.968..60211.232 rows=2625 loops=1)
>    Sort Key: public.logdata_recent."timestamp"
>    ->  Result  (cost=0.00..82.41 rows=6 width=14) (actual time=52.483..60200.868 rows=2625 loops=1)
>          ->  Append  (cost=0.00..82.41 rows=6 width=14) (actual time=52.476..60189.929 rows=2625 loops=1)
>                ->  Seq Scan on logdata_recent  (cost=0.00..46.25 rows=1 width=14) (actual time=0.003..0.003 rows=0
loops=1)
>                      Filter: (((logfielddatatype = 70) OR (logfielddatatype = 71) OR (logfielddatatype = 69)) AND
(graphtargetlog= 1327) AND ("timestamp" >= 1123052400) AND ("timestamp" <= 1123138800)) 
>                ->  Index Scan using logdata_recent_1123085306_ix_t_fld_gtl, logdata_recent_1123085306_ix_t_fld_gtl,
logdata_recent_1123085306_ix_t_fld_gtlon logdata_recent_stale logdata_recent  (cost=0.00..18.08 rows=3 width=14)
(actualtime=52.465..60181.624 rows=2625 loops=1) 

Notice here that expected rows is 3, but actual rows is a hell of a lot
higher. Try increasing stats collections for the columns on which
logdata_recent_1123085306_ix_t_fld_gtl is declared.

Also, the actual index scan is taking a long time. How recently have you
vacuum full'd?

Thanks,

Gavin

pgsql-performance by date:

Previous
From: "Jeffrey W. Baker"
Date:
Subject: Re: Query plan looks OK, but slow I/O - settings advice?
Next
From: "Roger Hand"
Date:
Subject: Re: Query plan looks OK, but slow I/O - settings advice?