Slow query-plan generation (fast query) PG 9.2

From: jesper(at)krogh(dot)cc
To: pgsql-performance(at)postgresql(dot)org
Subject: Slow query-plan generation (fast query) PG 9.2
Date: 2013-09-03 07:46:02
Message-ID: e9ed24069c06d8b504fbef3e28df52d7.squirrel@shrek.krogh.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi.

I have a strange situation where generating the query plan takes 6s+ and
executing it takes very little time.

2013-09-03 09:19:38.726 db=# explain select table.id from db.table left
join db.tablepro on db.id = tablepro.table_id where table.fts @@
to_tsquery('english','q12345') ;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Nested Loop Left Join (cost=43.71..12711.39 rows=2930 width=4)
-> Bitmap Heap Scan on sequence (cost=43.71..4449.10 rows=2930 width=4)
Recheck Cond: (fts @@ '''q12345'''::tsquery)
-> Bitmap Index Scan on table_gin_idx (cost=0.00..42.98
rows=2930 width=0)
Index Cond: (fts @@ '''q12345'''::tsquery)
-> Index Only Scan using tablepro_seqid_idx on tablepro
(cost=0.00..2.81 rows=1 width=4)
Index Cond: (tablepro_id = table.id)
(7 rows)

Time: 10458.404 ms

The query gives 4 rows out of 50.000.000, so the query-plan is actually
correct and as expected.

Any suggestions?

Jesper

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Craig Ringer 2013-09-03 07:47:08 Re: Slow query-plan generation (fast query) PG 9.2
Previous Message Torsten Förtsch 2013-09-02 19:57:04 planner parameters