Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1egsLa-0004l2-Co for pgsql-general@arkaria.postgresql.org; Wed, 31 Jan 2018 13:22:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egsLY-0002ub-7n for pgsql-general@arkaria.postgresql.org; Wed, 31 Jan 2018 13:22:40 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1egsLX-0002uS-TR for pgsql-general@lists.postgresql.org; Wed, 31 Jan 2018 13:22:40 +0000 Received: from troz.pl ([37.187.125.115]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1egsLV-0002gN-8d for pgsql-general@lists.postgresql.org; Wed, 31 Jan 2018 13:22:38 +0000 Received: from [192.168.1.140] (3224033-cl69.boa.fiberby.dk [89.23.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by troz.pl (Postfix) with ESMTPSA id 2B17D1E1; Wed, 31 Jan 2018 14:22:36 +0100 (CET) Subject: Re: Recreating functions after starting the database server. To: Achilleas Mantzios , pgsql-general@lists.postgresql.org References: <62735ca9-2245-8a56-acd5-20f7871244d8@FreeBSD.org> From: Konrad Witaszczyk Message-ID: Date: Wed, 31 Jan 2018 14:22:25 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="d9dbyy3OGEJnsjhuNPjTtGLGLaUWwmlup" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --d9dbyy3OGEJnsjhuNPjTtGLGLaUWwmlup Content-Type: multipart/mixed; boundary="wxD1F9PTIGfVXv0CsfQIvpNG9DACjg3Yg"; protected-headers="v1" From: Konrad Witaszczyk To: Achilleas Mantzios , pgsql-general@lists.postgresql.org Message-ID: Subject: Re: Recreating functions after starting the database server. References: <62735ca9-2245-8a56-acd5-20f7871244d8@FreeBSD.org> In-Reply-To: --wxD1F9PTIGfVXv0CsfQIvpNG9DACjg3Yg Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 01/31/2018 14:03, Achilleas Mantzios wrote: > On 31/01/2018 14:45, Konrad Witaszczyk wrote: >> Hi, >> >> I'm considering changing my database schema upgrade routines to recrea= te >> functions and all objects depending on them (e.g. triggers, views) jus= t after >> the database server is started. It would make the routines much simple= r since >> they wouldn't have to depend on the history of the schema. >> >> Does anyone has any experience with recreating all functions and trigg= ers to >> upgrade a database schema assuming that during the upgrade there are n= o client >> connections to the database? >> >> Does anyone see any problems with such approach in terms of consistenc= y and >> performance? I'm not familiar with PostgreSQL internals and I'm not su= re how it >> would affect the planner when using various function volatile categori= es. > Do you have indexes that use those functions? There are no indexes which use functions. I can see it would be a problem= in the other case since indexes would have to be rebuilt. Thanks for pointing it= out. > It would help to just give an example of your situation and what you ar= e trying > to solve. In my case the upgrade routines run migration scripts which modify a data= base schema. Besides that I have a bunch of SQL files with the schema that can= be used to initialize a new database. > Why recreate triggers, indexes and functions after server startup inste= ad of > leaving them? > Why create needless traffic? I would like to eliminate the migration scripts to have all definitions i= n one file which would be easier to maintain. I'm mainly interested in function= s and hence objects depending on them. However I wouldn't like to recreate inde= xes as it's not needed. >> >> >> Konrad --wxD1F9PTIGfVXv0CsfQIvpNG9DACjg3Yg-- --d9dbyy3OGEJnsjhuNPjTtGLGLaUWwmlup Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEE/bUwFm9Qs8vtm2934cEiWwsmpPAFAlpxwxFfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEZE QjUzMDE2NkY1MEIzQ0JFRDlCNkY3N0UxQzEyMjVCMEIyNkE0RjAACgkQ4cEiWwsm pPBAjhAAi17II5/6vY/FHZF9NegCu9L8WKEhlvlqkuEPcLnINeCmQ4xeaIN29Bzl Y5hl8q7nZVNJ/hygWb0ETr44lssPQHubNTmktfIe3W4T4qvy0tUfgr8IbsOXPyfa 7WB4OKpcf4d6j5Di/c+Q01eq4FhK+g6kSKRQ/FGMmCvBFQTy5Qwxcp062TP/RO8t Xck7DKUvjrrRF/iGue0S3f0vbeuJ3K3CEXt/6G/IKkWmAYJbPS2tfVmaJWSs6dQf TOLpkGZJB5p794K2V5b7k5J1so58m6M83khn4DXhAEIzR1EiCi0HPS8tsCUQHQbJ ZvZEGOPg+WW8D8RaV0MmMNbcsl4VTi7ELq/RaQPsAbCgKlxzN4yfkwTnGYP8F06b 65JQvieXaGhbSZ4qvDZZPW/OmmzNv1+RN3Dgoy8Z6kIzUyerbNjGteByUHosrwrz z5bTf09s0HABNXbL5iVwTVNVgh8RH1DdFFM2Pa4gWYYvEuflkqogg3cfwkhtL5J+ oulGsSbQzu+sm0gWbY6q0aOijn6cp8h1Qe9lQCxQZNWUj2P+gg9VaczQIeM4m4QA VG8Z/64aX93PSutSUIhsobqoaLZ+8i9XLRmnZfSSweM0GjJF2jT3qcQ3mS42Hfmi XLPqvgcfLxDztcD6RV9YPwGnHaHCP8mQDisP6TQdwtn79zWfeaY= =DCQ+ -----END PGP SIGNATURE----- --d9dbyy3OGEJnsjhuNPjTtGLGLaUWwmlup--