pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Dunstan <andrew@dunslane.net>
To: Greg Jaskiewicz <gryzman@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Dynamic queries in stored procedure
Date: Fri, 05 Jul 2013 10:26:42 -0400
Message-ID: <51D6D7A2.3030206@dunslane.net> (raw)
In-Reply-To: <96F5E9DF-8F6E-4EF6-B0AE-43B585B11F94@gmail.com>
References: <96F5E9DF-8F6E-4EF6-B0AE-43B585B11F94@gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>


On 07/05/2013 09:57 AM, Greg Jaskiewicz wrote:
> Hey,
>
> We have a search method that depending on search params will join 3-5 tables, craft the joins and where section. Only problem is, this is done in rather horrible java code. So using pgtap for tests is not feasible.
> I want to move the database complexity back to database, almost writing the query construction in the plpgsql or python as stores procedure, any suggestions ?
>
> Unfortunately PostgreSQL won't eliminate unnecessary joins from a view, so I can't just create one view and simple code adding where's, order by, etc.
>
> No, I don't want to use orm.
>

It's a matter of taste. Pretty much every PL has facilities for 
constructing and running dynamic sql. PLPgsql ,PLPerl, PLV8 ...

cheers

andrew




-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (4+ messages)  latest in thread

Message-ID: <51D6D7A2.3030206@dunslane.net>
Permalink:  ../51D6D7A2.3030206@dunslane.net/
Also on:    postgresql.org/message-id/51D6D7A2.3030206@dunslane.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: andrew@dunslane.net, gryzman@gmail.com
  Subject: Re: Dynamic queries in stored procedure
  In-Reply-To: <51D6D7A2.3030206@dunslane.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox