Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhfyp-0004mr-HI for pgsql-general@arkaria.postgresql.org; Thu, 21 Apr 2022 23:12:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nhfyn-0005q4-SU for pgsql-general@arkaria.postgresql.org; Thu, 21 Apr 2022 23:12:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhfym-0005pg-MV for pgsql-general@lists.postgresql.org; Thu, 21 Apr 2022 23:12:53 +0000 Received: from ook.raf.org ([139.99.156.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nhfyj-0002BK-65 for pgsql-general@lists.postgresql.org; Thu, 21 Apr 2022 23:12:52 +0000 Received: from localhost (localhost [127.0.0.1]) by ook.raf.org (Postfix) with ESMTP id 1EE0A5DE1E for ; Fri, 22 Apr 2022 09:12:39 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at ook.raf.org Received: from ook.raf.org ([127.0.0.1]) by localhost (ook.raf.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zq8HCkhcBE4b for ; Fri, 22 Apr 2022 09:12:38 +1000 (AEST) Received: by ook.raf.org (Postfix, from userid 1001) id 1E6485E4A1; Fri, 22 Apr 2022 09:12:38 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raf.org; s=001; t=1650582758; bh=Kz3cnX+oeb5oucy01RhAwUcxw0kEhrC3KtEeDXJ1b5Q=; h=Date:From:To:Subject:References:In-Reply-To:From; b=RC2KMFkxyc2ayOKc5nXa0OaESTdafhl43fKGIjsMgZPz/VhSxBpeCOR63H8rbAUms WunEhaUwebQl3dQRl9StWRVDAGIp1oBKbL5UnRNJN+ki+SGiaJfIWPEfeNDAYaDEdj C04QPGYJjEh4vEfq2gRD7rEJaxhzNvHKKYsMlmYz09MdsHyDM0vGAEVZx4J4fp6uPH p/wcaebB+goq8H4rFQY4ArcLTIlgLYNTdKgdOYXS7qHA0+ZFhQhpJdAjBU3eoZ9yDN KTIXY6/LSTEW6xM3gL1z7JI5RKcZ8n0typqmmnXoBh8wTgBNLz7i10ZbzY4TByLoL0 Dxeh/9cx9yv0g== Date: Fri, 22 Apr 2022 09:12:38 +1000 From: raf To: pgsql-general@lists.postgresql.org Subject: Re: Are stored procedures/triggers common in your industry Message-ID: References: <1D9B083B-8C41-4BB1-9A30-5ED2799AE963@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Apr 21, 2022 at 08:42:10AM -0500, Alex Aquino wrote: > You mentioned testing, and reminds me of another benefit. Way faster, more > reliable, cheaper to test on the DB side. Testing logic in SPs or SQL is > much easier, especially when testing requires a sequence of calls for a use > case. It is easier because of the DBs support for transactions. With > transactions and state management built into the DB, a testing process can > always revert to a reliable starting point and end point, thereby > facilitating more dependable, automated test harnesses. The alternative > done mostly now is testing via UIs or APIs where there is no inherent > transaction management, so a lot of work goes into preparing the test bed > to be a known state and introspecting the results to verify. This is > usually done with some mix of manual and automated processes. Actually, my full work tests take ages to run (~40m). I know that mocking the db to make unit tests fast is popular, but that's not helpful when the most important code being tested is in the database. :-) It's more important to me that the tests actually test everything than that they be fast. But yes, being able to do complex system testing with transaction rollback is great. cheers, raf