Re: New hook after raw parsing, before analyze - Mailing list pgsql-hackers

From Greg Stark
Subject Re: New hook after raw parsing, before analyze
Date
Msg-id CAM-w4HN=zg-SFQJOj6BUcuTg3ic0wn5zTxaMFJ168L4xqjV7Ag@mail.gmail.com
Whole thread Raw
In response to Re: New hook after raw parsing, before analyze  (David Beck <dbeck@starschema.net>)
List pgsql-hackers
On Fri, Feb 14, 2014 at 9:16 PM, David Beck <dbeck@starschema.net> wrote:
> What inspired me is the scriptable query rewrite in http://dev.mysql.com/downloads/mysql-proxy/
> The hook I proposed would be a lot nicer in Postgres because the raw parsing is already done at this point while in
mysql-proxythat has to be done manually.
 

There are a few similar things in the Postgres world such as pgbouncer
and plproxy but as you note they are limited in how powerful they can
be by the complexity of parsing and analyzing SQL.

I think Postgres tends to take a different tack regarding
extensibility than MySQL. Rather than have one system then hooks to
allow external code to modify or replace it, in Postgres modules
usually are treated similarly to the internal code. This is a pretty
broad generalization and there are certainly exceptions. But for
example new data types, functions, even whole new index types are all
treated almost identically to the internal data types, functions, and
index types. The planner then considers them all more or less on equal
basis.

Obviously there are limits. Btree indexes are kind of special because
they represent Postgres's basic concept of ordering. And we don't have
a pluggable recovery system which makes any externally provided index
types non-crash-safe. And we don't have a generalized concept of table
storage -- the closest thing we have is FDWs which is more like
MySQL's style of extensibility where the extension is a special case.

But this is why our instinct is that if you want to be able to push
down joins the way to do it is to extend the FDW api so that the
planner can make those decisions just like it makes the decisions
about internal joins rather than have an external module that takes
over part of the planner's work.

-- 
greg



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: New hook after raw parsing, before analyze
Next
From: Andres Freund
Date:
Subject: Re: Recovery inconsistencies, standby much larger than primary