Skip site navigation (1) Skip section navigation (2)

Re: FDW state from plan time

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FDW state from plan time
Date: 2011-04-03 16:38:37
Message-ID: 15101.1301848717@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Dave Page <dpage(at)pgadmin(dot)org> writes:
> I can't help thinking I must be missing something obvious here, but is
> there any way to persist some data from PlanForeignScan to at least
> BeginForeignScan in an FDW? I'm aware of fdwplan->fdw_private, but at
> that needs to be copyObject compatible, it's not much use to me.

> The issue I have is that in order to properly plan my remote scan, I
> need to connect to the remote database to try to calculate some stats
> for the query. I'm currently then disconnecting and freeing all the
> data associated with that connection, and then reconnecting again in
> BeginForeignScan in order to do the actual work. I'd like to avoid the
> connect/reconnect, as we all know they can be expensive!

I'd suggest that you reference your open connections with an integer
index, which you could then store in the plan node.  Plans don't have to
survive longer than the current backend, so this would be perfectly safe
so long as you don't re-use the indexes within a session.

Or you could use a hash of some other identifying information (perhaps
the OID of the foreign server would be sufficient ID for a connection?).

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2011-04-03 16:41:56
Subject: Re: Should psql support URI syntax?
Previous:From: Magnus HaganderDate: 2011-04-03 14:04:41
Subject: Re: Windows build issues

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group