Analyze makes queries slow...

From: Stef <svb(at)ucs(dot)co(dot)za>
To: pgsql-performance(at)postgresql(dot)org
Subject: Analyze makes queries slow...
Date: 2003-08-11 13:58:41
Message-ID: 20030811155841.483ffd93.svb@ucs.co.za
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi all,

I posted this problem on the sql list, and was referred to this list in stead.
I have attached an sql statement that normally runs under 3 minutes.
That is, until I vacuum analyze the database (or just the tables in the query),
then the same query runs longer than 12 hours, and I have to kill it.

However 90% of queries are faster after analyzing on this database,
there are two or three, including this one that takes for ever.

I have tried to reverse engineer the explain plan from before analyzing,
to come up with an sql statement, using proper joins, to force the planner
to do the original join, but although I came close, I never got the same
result as the original query.

I suspect that this might be caused by some of the crazy indexes that
were built on some of these tables, but I can't really do much about that,
unless I can come up with a very good reason to nuke them.

I also attached the "create table" statements for all the tables, as well
as a row count of each.

Can somebody help me with guidelines or something similar,
to understand exactly what is happening in the explain plan.

TIA
Stefan

Attachment Content-Type Size
explain_after.txt text/plain 3.4 KB
explain_before.txt text/plain 3.4 KB
forex.sql application/octet-stream 1.7 KB
master_branch_descr.sql application/octet-stream 5.4 KB
master_fpp_values.sql application/octet-stream 4.1 KB
master_sku_descr.sql application/octet-stream 3.7 KB
number_of_rows.txt text/plain 479 bytes
price_tmpl_det.sql application/octet-stream 583 bytes
sku_price.sql application/octet-stream 2.8 KB
sql_statement.sql application/octet-stream 2.0 KB
supplier_price.sql application/octet-stream 1.3 KB

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message scott.marlowe 2003-08-11 14:47:07 Re: Perfomance Tuning
Previous Message Shridhar Daithankar 2003-08-11 13:26:08 Re: Peformance of Update