Re: optimizing query

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Chantal Ackermann <chantal(dot)ackermann(at)biomax(dot)de>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: optimizing query
Date: 2003-01-22 16:20:15
Message-ID: 20030122081422.Y96911-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance


(Replying to general and performance in a hope to move this
to performance after a couple of replies).

On Wed, 22 Jan 2003, Chantal Ackermann wrote:

> I am getting the following output from EXPLAIN, concerning a query with
> joins. The merge uses index scans but takes too long, in my opinion. The
> query is in fact only a part (subquery) of another one, but it is the
> bottle neck.
>
> As I am quite ignorant in optimizing queries, and I have no idea where
> to find documentation on the net on how to learn optimizing my queries,
> I am posting this here in hope someone will give me either tips how to
> optimize, or where to find some tutorial that could help me get along on
> my own.
>
> dropping the "DISTINCT" has some effect, but I can't really do without.

The first thing is, have you done ANALYZE recently to make sure that the
statistics are correct and what does EXPLAIN ANALYZE give you (that will
run the query and give the estimate and actual). Also, if you haven't
vacuumed recently, you may want to vacuum full.

How many rows are there on gene, disease and both occurrances tables?
I'd wonder if perhaps using explicit sql join syntax (which postgres uses
to constrain order) to join disease and disease_occurrences_puid before
joining it to the other two would be better or worse in practice.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2003-01-22 16:20:49 Re: [part 2] How to backup a postgreSQL of 80 GByte ?
Previous Message Dmitry Alyabyev 2003-01-22 16:09:01 is 7.1.3 vulnerable ?

Browse pgsql-performance by date

  From Date Subject
Next Message Seth Robertson 2003-01-22 17:45:24 Re: Postgres 7.3.1 poor insert/update/search performance
Previous Message Tom Lane 2003-01-22 16:09:58 Re: Postgres 7.3.1 poor insert/update/search performance