On Sat, 28 Nov 1998, The Hermit Hacker wrote:
> On Sat, 28 Nov 1998, John Fieber wrote:
>
> > In working with the two, I've also found a couple complicated
> > join queries where I just couldn't get the optimizer in
> > PostgreSQL (6.3.2 and 6.4) to do the right thing, resulting in
> > several minutes of processing per query, while mySQL did the same
> > query in the blink of an eye.
>
> You mention v6.4 above, so could you provide us with a way of
> "reproducing" the bug?
Attached is the database scheme from pg_dump (there are a bunch
of extraneous tables in the context of this query). I make no
claims at all about the quality of the database design or the
query, but both Sybase and mySQL execute it very quickly while
PostgreSQL refuses to use the index on the codes table.
$sheet in the query is the "user input" to and is an integer.
(For the curious, this is part of
http://fallout.campusview.indiana.edu/mapfinder. I can supply
data if needed.)
-john
SELECT sheet.sheet_id, sheet.name, sheet.number, sheet.note, cat.call,
cat.series, cat.main_entry, sheet.scale, ca.name as mtype, cb.name as prod,
cc.name as proj, cd.name as pm, ce.name as format, sheet.coords FROM
sheet, cat, codes ca, codes cb, codes cc, codes cd, codes ce WHERE sheet.sheet_id = $sheet
AND sheet.cat_id = cat.cat_id AND sheet.mtype = ca.code_id AND sheet.prod = cb.code_id AND sheet.proj =
cc.code_id AND sheet.pm = cd.code_id AND sheet.format = ce.code_id