help with understanding EXPLAIN

From: Brandon Casci <brandon(at)loudcaster(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: help with understanding EXPLAIN
Date: 2010-10-13 21:18:10
Message-ID: AANLkTinocNKGsOLCJp34WDT=B_ps1js_xKY7MDo8Dcdq@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

Hello

I have an application hosted on Heroku. They use postgres. It's more or less
abstracted away, but I can get some performance data from New Relic. For the
most part, performance is ok, but now and then some queries take a few
seconds, and spike up to 15 or even 16 seconds! Ouch!

This is the most detailed information I could get form New Relic. Do you
have any suggestions how I could improve the performance?

QUERY PLANLimit (cost=26.49..1893.46 rows=1 width=4) QUERY PLAN -> Unique
(cost=26.49..44833.82 rows=24 width=4) QUERY PLAN -> Nested Loop
(cost=26.49..44833.81 rows=24 width=4) QUERY PLAN -> Merge Join
(cost=26.49..44532.99 rows=4773 width=8) QUERY PLAN Merge Cond: (songs.id =
artists_songs.song_id) QUERY PLAN -> Index Scan using songs_pkey on songs
(cost=0.00..25219.30 rows=4773 width=4) QUERY PLAN Filter:
(lower((name)::text) = 'thirteen'::text) QUERY PLAN -> Index Scan using
index_artists_songs_on_song_id on artists_songs (cost=0.00..18822.04
rows=960465 width=8) QUERY PLAN -> Index Scan using artists_pkey on artists
(cost=0.00..0.06 rows=1 width=4) QUERY PLAN Index Cond: (artists.id =
artists_songs.artist_id) QUERY PLAN Filter: (lower((artists.name)::text) =
'red mountain church'::text)

--
=========================================
Brandon Casci
Loudcaster
http://loudcaster.com
=========================================

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Osvaldo Kussama 2010-10-13 21:19:13 Re: How to search ignoring spaces and minus signs
Previous Message ljb 2010-10-13 21:03:43 Re: Gripe: bytea_output default => data corruption

Browse pgsql-performance by date

  From Date Subject
Next Message Joe Miller 2010-10-13 21:20:11 Re: Auto ANALYZE criteria
Previous Message Mark Kirkwood 2010-10-13 21:07:07 Re: Slow count(*) again...