Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uv6Vd-0000FZ-GE for pgsql-performance@arkaria.postgresql.org; Fri, 05 Jul 2013 13:57:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Uv6Vc-0007aW-RR for pgsql-performance@arkaria.postgresql.org; Fri, 05 Jul 2013 13:57:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uv6Vb-0007aP-OR for pgsql-performance@postgresql.org; Fri, 05 Jul 2013 13:57:11 +0000 Received: from mail-ea0-x233.google.com ([2a00:1450:4013:c01::233]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uv6VY-0005Wh-Cl for pgsql-performance@postgresql.org; Fri, 05 Jul 2013 13:57:11 +0000 Received: by mail-ea0-f179.google.com with SMTP id b15so1516598eae.10 for ; Fri, 05 Jul 2013 06:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:content-type:x-mailer:message-id:date:to :content-transfer-encoding:mime-version; bh=M/QcLSCqCCZS3hujd1dSRYiEDZyPhOXkDVOExzXPa2o=; b=HBJgtuLJSAR71bTYIAtRa6GSbfshwZZSLIXRCSj2khBXQtRakOb1dAhIpElZQ8/dG8 eVGeyoRD98vhoYhV+gIZgZqGqht3BA0a4FmMjMvtz6uJbYllRI470MbyXCLG9TLfTtrL U4jsd0eI8agI4EYtHZYIgiCe0vaoDQ5EBGH7ROLjeG9NgjY/UVIt4oN/fHKPaWfTWywI k+lxZNpWzJ5g0/B4nlVSUk1Vm4qdx5bk9zbydVC9qxZr1k9Y0qkyrzkBBAEA98mfYy+D w00hj49KuBVPN38TrKV5/8nUWfgOIgUQGVxJmvIxn7xxKKHO3gBDXD12Iqq8JTS4nWT7 LphQ== X-Received: by 10.14.7.133 with SMTP id 5mr12460739eep.115.1373032626819; Fri, 05 Jul 2013 06:57:06 -0700 (PDT) Received: from [192.168.251.33] (outbound.latens.co.uk. [81.134.2.201]) by mx.google.com with ESMTPSA id b7sm14057522eef.16.2013.07.05.06.57.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Jul 2013 06:57:05 -0700 (PDT) Subject: Dynamic queries in stored procedure From: Greg Jaskiewicz Content-Type: text/plain; charset=us-ascii X-Mailer: iPad Mail (10B329) Message-Id: <96F5E9DF-8F6E-4EF6-B0AE-43B585B11F94@gmail.com> Date: Fri, 5 Jul 2013 14:57:06 +0100 To: pgsql-performance@postgresql.org Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hey, We have a search method that depending on search params will join 3-5 table= s, craft the joins and where section. Only problem is, this is done in rath= er 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 sugge= stions ? 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. Thanks.=20 --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance