Re: [SQL] SQL Query Optimization

From: Dav Coleman <dav(at)danger-island(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [SQL] SQL Query Optimization
Date: 2002-04-18 16:07:09
Message-ID: 20020418090709.H24932@danger-island.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm sorry, I realized after posting this that it went to the wrong
list, I resent it to pgsql-sql instead.

But basically I haven't done any ANALYZE or EXPLAIN yet because of the
fact that the order -is- making a difference so it can't be executing
the same query inside the database engine. Given that, I figured I would
jsut look for theories on how to rewrite the queries before submitting first.

btw, we are using postgresql 7.1.2 compiled from source on rh linux 7.0.

I also might not have been very clear about the fact that the user is
basically constructing the query dynamically in the application, so it's
not a matter of just optimizing any specifc query, but any possible query.

Tom Lane [tgl(at)sss(dot)pgh(dot)pa(dot)us] wrote:
> Dav Coleman <dav(at)serve(dot)com> writes:
> > I have noticed that the semantically equivalent SQL queries can
> > differ
> > vastly in speed performance depending on the order of clauses ANDed
> > together ( "WHERE cond1 AND cond2" takes forever, but "WHERE cond2
> > AND cond1" comes right back).
>
> Could we see a specific example?
>
> It would also be useful to know what PG version you are using, whether
> you've VACUUM ANALYZEd the tables, and what EXPLAIN has to say about
> your query.
>
> regards, tom lane

--
Dav Coleman
http://www.danger-island.com/dav/

--
Dav Coleman
http://www.danger-island.com/dav/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Loftis 2002-04-18 16:10:37 Re: Index Scans become Seq Scans after VACUUM ANALYSE
Previous Message Alvaro Herrera 2002-04-18 16:05:35 Re: regexp character class locale awareness patch