Re: fool-toleranced optimizer - Mailing list pgsql-hackers

From Neil Conway
Subject Re: fool-toleranced optimizer
Date
Msg-id 422EE03B.3080706@samurai.com
Whole thread Raw
In response to Re: fool-toleranced optimizer  (Simon Riggs <simon@2ndquadrant.com>)
Responses Re: fool-toleranced optimizer  (Simon Riggs <simon@2ndquadrant.com>)
Re: fool-toleranced optimizer  (Greg Stark <gsstark@mit.edu>)
Re: fool-toleranced optimizer  (Kevin Brown <kevin@sysexperts.com>)
List pgsql-hackers
Simon Riggs wrote:
> Oleg is saying that the optimizer doesn't protect against foolish SQL
> requests. His query is an example of a foolishly written query.

IMHO calling this a "foolishly written query" is completely arbitrary. I 
can imagine plenty of applications for which a cartesian join makes 
sense. In this case the user didn't write the query they meant to write 
-- but it is surely hopeless to prevent that in the general case :)

> It seems a reasonable that there might be a GUC such as 
> enable_cartesian = on (by default)

I think the bar for adding a new GUC ought to be significantly higher 
than that.

In any case, when this problem does occur, it is obvious to the user 
that something is wrong, and no harm is done. Given a complex SQL query, 
it might take a bit of examination to determine which join clause is 
missing -- but the proper way to fix that is better query visualization 
tools (perhaps similar RH's Visual Explain, for example). This would 
solve the general problem: "the user didn't write the query they 
intended to write", rather than a very narrow subset ("the user forgot a 
join clause and accidentally computed a cartesian product").

-Neil


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: fool-toleranced optimizer
Next
From: Simon Riggs
Date:
Subject: Re: fool-toleranced optimizer