pg.ddx.io pgsql-performance@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Index Performance Help 5+ messages / 4 participants [nested] [flat]
* Index Performance Help @ 2004-02-05 12:13 Damien Dougan <damien.dougan@mobilecohesion.com> 0 siblings, 2 replies; 5+ messages in thread From: Damien Dougan @ 2004-02-05 12:13 UTC (permalink / raw) To: pgsql-performance Hi All, I've been seeing very slow read performance on a database of 1 million indexed subscribers, which I believe is nothing to do with the data itself, but delays on processing the index. If I make a random jump into the index (say X), it can take about 50ms to read the subscriber. If I then make a "close by" lookup (say X+10), it takes only about 0.5ms to read the subscriber. Making another lookup to a "far away" (say X+1000), it again takes about 50ms to read. ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Index Performance Help @ 2004-02-05 15:54 Richard Huxton <dev@archonet.com> parent: Damien Dougan <damien.dougan@mobilecohesion.com> 1 sibling, 1 reply; 5+ messages in thread From: Richard Huxton @ 2004-02-05 15:54 UTC (permalink / raw) To: Damien Dougan <damien.dougan@mobilecohesion.com>; pgsql-performance On Thursday 05 February 2004 12:13, Damien Dougan wrote: > Hi All, > > I've been seeing very slow read performance on a database of 1 million > indexed subscribers, which I believe is nothing to do with the data > itself, but delays on processing the index. > > If I make a random jump into the index (say X), it can take about 50ms > to read the subscriber. If I then make a "close by" lookup (say X+10), > it takes only about 0.5ms to read the subscriber. Making another lookup > to a "far away" (say X+1000), it again takes about 50ms to read. The first time, it has to fetch a block from disk. The second time that disk block is already in RAM so it's much faster. The third time it needs a different disk block. > Am I correct in my analysis? Is there anything I can do to improve the > performance of the index lookups? Make sure you have enough RAM to buffer your disks. Buy faster disks. > I've tried increasing the index memory and making a number of queries > around the index range, but a stray of several hundred indexes from a > cached entry always results in a major lookup delay. Yep, that'll be your disks. > I've also increased the shared memory available to Postgres to 80MB > incase this is a paging of the index, but it hasn't seemed to have any > effect. Probably the wrong thing to do (although you don't mention what hardware you've got). Read the tuning document at: http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php > Sample analyze output for an initial query: > > hydradb=# explain analyze select * from pvsubscriber where actorid = > 'b3432-asdas-232-Subscriber793500'; ... > -> Index Scan using mc_actor_key on mc_actor > (cost=0.00..4.08 rows=1 width=69) (actual time=39.497..39.499 rows=1 > loops=1) ... > Total runtime: 49.845 ms > And the analyze output for a "nearby" subscriber (10 indexes away): > > hydradb=# explain analyze select * from pvsubscriber where actorid = > 'b3432-asdas-232-Subscriber793510'; > ... > -> Index Scan using mc_actor_key on mc_actor > (cost=0.00..4.08 rows=1 width=69) (actual time=0.220..0.221 rows=1 > loops=1) > Total runtime: 0.428 ms > (15 rows) That certainly seems to be the big change - the only way to consistently get 1ms timings is going to be to make sure all your data is cached. Try the tuning guide above and see what difference that makes. If that's no good, post again with details of your config settings, hardware, number of clients etc... -- Richard Huxton Archonet Ltd ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Index Performance Help @ 2004-02-05 16:40 Damien Dougan <damien.dougan@mobilecohesion.com> parent: Richard Huxton <dev@archonet.com> 0 siblings, 1 reply; 5+ messages in thread From: Damien Dougan @ 2004-02-05 16:40 UTC (permalink / raw) To: 'Richard Huxton' <dev@archonet.com>; pgsql-performance Thanks Richard. It certainly does appear to be memory related (on a smaller data set of 250K subscribers, all accesses are < 1ms). We're going to play with increasing RAM on the machine, and applying the optimisation levels on the page you recommended. (We're also running on a hardware RAID controlled SCSI set - mirrored disks so reading should be very fast). Cheers, Damien ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Index Performance Help @ 2004-02-05 18:28 Josh Berkus <josh@agliodbs.com> parent: Damien Dougan <damien.dougan@mobilecohesion.com> 0 siblings, 0 replies; 5+ messages in thread From: Josh Berkus @ 2004-02-05 18:28 UTC (permalink / raw) To: Damien Dougan <damien.dougan@mobilecohesion.com>; 'Richard Huxton' <dev@archonet.com>; pgsql-performance Damian, Also, if there have been a lot of updates to the table, you may need to run a REINDEX on it. An attenuated index would be slow to load because of the nummber of empty disk blocks. -- -Josh Berkus Aglio Database Solutions San Francisco ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Index Performance Help @ 2004-04-02 04:44 Greg Stark <gsstark@mit.edu> parent: Damien Dougan <damien.dougan@mobilecohesion.com> 1 sibling, 0 replies; 5+ messages in thread From: Greg Stark @ 2004-04-02 04:44 UTC (permalink / raw) To: Damien Dougan <damien.dougan@mobilecohesion.com>; +Cc: pgsql-performance "Damien Dougan" <damien.dougan@mobilecohesion.com> writes: > Sample analyze output for an initial query: > > hydradb=# explain analyze select * from pvsubscriber where actorid = > 'b3432-asdas-232-Subscriber793500'; I take it pvsubscriber is a view? What's the definition of your view? > -> Index Scan using mc_actor_key on mc_actor > (cost=0.00..4.08 rows=1 width=69) > (actual time=39.497..39.499 rows=1 loops=1) Is this table regularly vacuumed? Is it possible it has lots of dead records with this value for actorid? Try running vacuum full, or better "vacuum full verbose" and keep the output, it might explain. What version of postgres is this? You might try reindexing all your indexes (but particularly this one). Older versions of postgres were prone to index bloat problems. -- greg ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2004-04-02 04:44 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2004-02-05 12:13 Index Performance Help Damien Dougan <damien.dougan@mobilecohesion.com> 2004-02-05 15:54 ` Richard Huxton <dev@archonet.com> 2004-02-05 16:40 ` Damien Dougan <damien.dougan@mobilecohesion.com> 2004-02-05 18:28 ` Josh Berkus <josh@agliodbs.com> 2004-04-02 04:44 ` Greg Stark <gsstark@mit.edu>
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