Re: Application written in pure pgsql, good idea? - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Application written in pure pgsql, good idea?
Date
Msg-id CAHyXU0yF25WEzRd2RBxnnUY4=frapTDT5e3oZRVDgjURnLN=9g@mail.gmail.com
Whole thread Raw
In response to Application written in pure pgsql, good idea?  (inspector morse <inspectormorse86@gmail.com>)
List pgsql-general
On Sat, Feb 28, 2015 at 2:39 PM, inspector morse
<inspectormorse86@gmail.com> wrote:
>
> Is it a good idea to write a simple application (consisting of just data
> entry interfaces) in pure pgsql?
>
> Basically, we would have each page has a stored function in postgresql that
> is called by php+apache (the http get/post values would be passed into
> postgrel as an array).
>
> The pgpsql would render HTML and return back to the front end for display.
>
> Sample:
> create function render_user_login_page(out v_html varchar)
> returns varchar
> as
> $$
> begin
>      v_html := v_html || '<table><tr><td>User ID:</td><td><input type="text"
> /></td></tr></table>';
> end;
> $$
>
>
> Would there be any performance issues with doing this?

I think this idea is pretty neat.  Posgres string processing will
likely not be performance competitive with some of the more popular
string processing engines, but it should be fast enough to get the job
done in any cases.  Some general tips:

*) format() function will often yield more readable code than
excessive string concatentation via || or concat()
*) consider serving static html (perhaps directly via web server vs
database rendered) and rethink your strategy to have the database
compose json which is post rendered in the browser. This is a very
powerful strategy
*) advise liberally using powerful javascript libraries (slickgrid,
highcharts, google visualizations, etc) vs doing database based
constructions of same

merlin


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: The slave suddenly stopped with such DB log : "will not overwrite a used ItemId" and "heap_insert_redo: failed to add tuple"
Next
From: David Kerr
Date:
Subject: Replication fell out of sync