Re: Roadmap for FE/BE protocol redesign

From: Christof Petig <christof(at)petig-baender(dot)de>
To: Barry Lind <blind(at)xythos(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Roadmap for FE/BE protocol redesign
Date: 2003-03-13 15:40:25
Message-ID: 3E70A669.2040905@petig-baender.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-interfaces

Barry Lind wrote:
> 3) Protocol level support for CURSORs. It would be nice if cursor
> support was done at the protocol level and not as a SQL command.

I want to second this proposal. Currently I avoid using cursors in my
programs since
a) they need much more logic and _string_concatenation_ to be handled
transparently by a library (prepend the query with DECLARE X CURSOR
FOR), then (FETCH n FROM X), then (CLOSE X). That's inefficient.
b) I have a really bad feeling to have the backend parse (FETCH FROM X)
every time I ask for a (single) row
c) I hate that the backend retransmits column names etc. for every fetch
I issue. This information is mostly unneeded but the backend cannot know
better

Of course these issues can be addressed by using FETCH n (n>10) but this
kludge is only needed because the FETCH protocol is so inefficient.
Think about the amount of bytes transferred for "select 2000 lines of
integers" with and without declare/fetch/close. Imagine a result set of
1 to 20000 integers given back (depending on parameters) for an
interactive program (e.g. browsing a customer list by initials). Prefer
a cursor (much more constant overhead even for single results) or all in
one (and wait longer for a first result)?

I'd love to tell the backend to give a "descriptor" for this query back
and use it efficiently to get data and/or metadata (see ODBC, JDBC,
sqlda or dynamic sql). Perhaps it's most efficient to ask for N initial
results (which are instantly returned).

Christof (who implemented dynamic sql for ecpg)

PS: perhaps this protocol infrastructure is also well suited to return
large bytea values (<M bytes : return inline, > return a descriptor).
[Also proposed by Barry Lind.]

PPS: I'm perfectly fine with returning attrelid/attnum. Then the client
can control how many effort is spent for determining only the asked for
metadata.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Cramer 2003-03-13 15:41:40 Re: Request for quote looking to pay for work
Previous Message cbbrowne 2003-03-13 15:35:43 Re: Roadmap for FE/BE protocol redesign

Browse pgsql-interfaces by date

  From Date Subject
Next Message Marc G. Fournier 2003-03-13 16:07:26 Re: Roadmap for FE/BE protocol redesign
Previous Message Gerhard Häring 2003-03-13 15:36:08 Re: Seg fault on completing query