pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: mark <markkicks@gmail.com>
To: depesz@depesz.com
Cc: Justin <justin@emproshunts.com>
Cc: pgsql-performance@postgresql.org, PFC <lists@peufeu.com>
Subject: Re: [GENERAL] select query takes 13 seconds to run with index
Date: Tue, 27 May 2008 07:46:05 -0700
Message-ID: <82fa9e310805270746u56334348m34055cb31219ff45@mail.gmail.com> (raw)
In-Reply-To: <20080527082201.GA17943@depesz.com>
References: <82fa9e310805261549m2362fbe8sbf18789938fee833@mail.gmail.com>
	<483B4729.7050402@emproshunts.com>
	<82fa9e310805261632y46f306fdh84e2da62ffbd7873@mail.gmail.com>
	<20080527082201.GA17943@depesz.com>

On Tue, May 27, 2008 at 1:22 AM, hubert depesz lubaczewski
<depesz@depesz.com> wrote:
> On Mon, May 26, 2008 at 04:32:50PM -0700, mark wrote:
>> >> EXPLAIN ANALYZE select * from pokes where uid = 578439028 order by id
>> >> DESC limit 6;
>> > The estimate is way off, when was the last time Vaccum was on the table?
>> about a week ago i ran this VACUUM VERBOSE ANALYZE;
>> this table is never updated or deleted, rows are just inserted...
>
> 1. boost default_statistics_target
> 2. run analyze more often - daily job for example
> 3. create index q on pokes (uid, id); should help

OK I did this

ALTER TABLE pokes ALTER uid set statistics 500;
ALTER TABLE

ANALYZE pokes;
ANALYZE

and then it became super fast!! thanks a lot!!!
my question:
-> is 500 too high? what all does this affect?
-> now increasing this number does it affect only when i am running
analyze commands, or will it slow down inserts and other operations?
EXPLAIN ANALYZE select * from pokes where uid = 578439028 order by id
desc limit 6;
                                                             QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------
 Limit  (cost=467.80..467.81 rows=6 width=134) (actual
time=0.016..0.016 rows=0 loops=1)
  ->  Sort  (cost=467.80..468.09 rows=117 width=134) (actual
time=0.016..0.016 rows=0 loops=1)
        Sort Key: id
        Sort Method:  quicksort  Memory: 25kB
        ->  Index Scan using idx_pokes_uid on pokes
(cost=0.00..465.70 rows=117 width=134) (actual time=0.011..0.011
rows=0 loops=1)
              Index Cond: (uid = 578439028)
 Total runtime: 0.037 ms



view thread (16+ messages)  latest in thread

Message-ID: <82fa9e310805270746u56334348m34055cb31219ff45@mail.gmail.com>
Permalink:  ../82fa9e310805270746u56334348m34055cb31219ff45@mail.gmail.com/
Also on:    postgresql.org/message-id/82fa9e310805270746u56334348m34055cb31219ff45@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: markkicks@gmail.com, depesz@depesz.com, justin@emproshunts.com, lists@peufeu.com
  Subject: Re: [GENERAL] select query takes 13 seconds to run with index
  In-Reply-To: <82fa9e310805270746u56334348m34055cb31219ff45@mail.gmail.com>
  References: <82fa9e310805261549m2362fbe8sbf18789938fee833@mail.gmail.com> <483B4729.7050402@emproshunts.com> <82fa9e310805261632y46f306fdh84e2da62ffbd7873@mail.gmail.com> <20080527082201.GA17943@depesz.com> <82fa9e310805270746u56334348m34055cb31219ff45@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox