Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] select query takes 13 seconds to run with index

From: mark <markkicks(at)gmail(dot)com>
To: depesz(at)depesz(dot)com
Cc: Justin <justin(at)emproshunts(dot)com>, pgsql-performance(at)postgresql(dot)org, PFC <lists(at)peufeu(dot)com>
Subject: Re: [GENERAL] select query takes 13 seconds to run with index
Date: 2008-05-27 14:46:05
Message-ID: 82fa9e310805270746u56334348m34055cb31219ff45@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-performance
On Tue, May 27, 2008 at 1:22 AM, hubert depesz lubaczewski
<depesz(at)depesz(dot)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

In response to

Responses

pgsql-performance by date

Next:From: hubert depesz lubaczewskiDate: 2008-05-27 14:58:19
Subject: Re: [GENERAL] select query takes 13 seconds to run with index
Previous:From: hubert depesz lubaczewskiDate: 2008-05-27 08:22:01
Subject: Re: [PERFORM] select query takes 13 seconds to run with index

pgsql-general by date

Next:From: Andrew SullivanDate: 2008-05-27 14:52:22
Subject: Re: New MS patent: sounds like PG db rules
Previous:From: Tom LaneDate: 2008-05-27 14:41:50
Subject: Re: New MS patent: sounds like PG db rules

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group