Re: Simple join optimized badly?

From: "Craig A(dot) James" <cjames(at)modgraph-usa(dot)com>
To: Brian Herlihy <btherl(at)yahoo(dot)com(dot)au>
Cc: Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Simple join optimized badly?
Date: 2006-10-10 03:16:28
Message-ID: 452B108C.7020703@modgraph-usa.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Brian Herlihy wrote:
> PG does support hints actually..
> The only thing is, the hints are expressed in an obscure, ad-hoc and
> implementation dependant language.
>
> For example, the "Don't use index X" hint (the one I used) can be accessed by
> replacing your index with an index on values derived from the actual index...

And then there's

select ... from (select ... offset 0)

where the "offset 0" prevents any rewriting between the two levels of query. This replaces joins and AND clauses where the planner makes the wrong choice of join order or filtering. I grepped my code and found four of these (all workarounds for the same underlying problem).

Imagine I got run over by a train, and someone was reading my code. Which would be easier for them to maintain: Code with weird SQL, or code with sensible, well-written SQL and explicit hints? Luckily for my (hypothetical, I hope) successor, I put massive comments in my code explaining the strange SQL.

The bad applications are ALREADY HERE. And they're WORSE to maintain than if we had a formal hint language. The argument that hints lead to poor application is true. But lack of hints leads to worse applications.

Craig

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Joshua D. Drake 2006-10-10 03:22:39 Re: Simple join optimized badly?
Previous Message Brian Herlihy 2006-10-10 01:10:42 Re: Simple join optimized badly?