Re: Convert query plan to sql query

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: mariem <mariem(dot)benfadhel(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Convert query plan to sql query
Date: 2014-11-08 14:30:18
Message-ID: CA+TgmoZgvM7wyxYdV60E+ctE1y=+dbOUNcCENATK7x3TqhdqLA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 8, 2014 at 1:09 AM, mariem <mariem(dot)benfadhel(at)gmail(dot)com> wrote:
> Hi Tom,
>>If you don't need that, why are you insistent on extracting the
>>information from a plan tree?
>
> I need to resolve expressions and apply rewrite rules before I reverse the
> query plan to a query.
>
>>It seems far simpler to me to make use of ruleutils.c to reverse-list
>>the original parsetree. That functionality already exists and is well
>>tested and well maintained. If you insist on working from a plan tree,
>>you will be writing a fair amount of code that you will have to maintain
>>yourself. And I absolutely, positively guarantee that we will break it
>>in every major release, and occasionally in minor releases. You should
>>read the git history of explain.c and ruleutils.c and ask yourself whether
>>you want to keep up with that level of churn.
>
> I'm aware of ruleutils.c which I think is a good tool but I don't think it's
> appropriate as it takes the parse tree as input.

"Parse", "Rewrite", and "Plan" are distinct stages. ruleutils.c takes
the tree that results from rewriting, before planning has been done.
So I'm not sure it's quite accurate to say that it takes the "parse
tree" - rewrite rules will already have been applied.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-11-08 14:42:40 Re: tracking commit timestamps
Previous Message Robert Haas 2014-11-08 14:26:45 Re: row_to_json bug with index only scans: empty keys!