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 1egscV-0005qq-DI for pgsql-general@arkaria.postgresql.org; Wed, 31 Jan 2018 13:40:11 +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 1egscU-0007Uh-2G for pgsql-general@arkaria.postgresql.org; Wed, 31 Jan 2018 13:40:10 +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 1egscT-0007UK-NN for pgsql-general@lists.postgresql.org; Wed, 31 Jan 2018 13:40:09 +0000 Received: from troz.pl ([37.187.125.115]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1egscP-000314-Fl for pgsql-general@lists.postgresql.org; Wed, 31 Jan 2018 13:40:08 +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 530BB1E7; Wed, 31 Jan 2018 14:40:04 +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: <55917059-846c-8d33-8732-2e1a434d3846@FreeBSD.org> Date: Wed, 31 Jan 2018 14:39:54 +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="9Y5HKFZ1s8EM8gwGV36LeG28IsaZ15jWz" 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) --9Y5HKFZ1s8EM8gwGV36LeG28IsaZ15jWz Content-Type: multipart/mixed; boundary="AbhNZvurQGq9rKAmcHFQbBXQCmdmYydXb"; protected-headers="v1" From: Konrad Witaszczyk To: Achilleas Mantzios , pgsql-general@lists.postgresql.org Message-ID: <55917059-846c-8d33-8732-2e1a434d3846@FreeBSD.org> Subject: Re: Recreating functions after starting the database server. References: <62735ca9-2245-8a56-acd5-20f7871244d8@FreeBSD.org> In-Reply-To: --AbhNZvurQGq9rKAmcHFQbBXQCmdmYydXb Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US On 01/31/2018 14:32, Achilleas Mantzios wrote: > On 31/01/2018 15:22, Konrad Witaszczyk wrote: >> 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 recr= eate >>>> functions and all objects depending on them (e.g. triggers, views) j= ust after >>>> the database server is started. It would make the routines much simp= ler since >>>> they wouldn't have to depend on the history of the schema. >>>> >>>> Does anyone has any experience with recreating all functions and tri= ggers to >>>> upgrade a database schema assuming that during the upgrade there are= no client >>>> connections to the database? >>>> >>>> Does anyone see any problems with such approach in terms of consiste= ncy and >>>> performance? I'm not familiar with PostgreSQL internals and I'm not = sure >>>> how it >>>> would affect the planner when using various function volatile catego= ries. >>> Do you have indexes that use those functions? >> There are no indexes which use functions. I can see it would be a prob= lem 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 = are trying >>> to solve. >> In my case the upgrade routines run migration scripts which modify a d= atabase >> 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 ins= tead of >>> leaving them? >>> Why create needless traffic? >> I would like to eliminate the migration scripts to have all definition= s in one >> file which would be easier to maintain. I'm mainly interested in funct= ions and >> hence objects depending on them. However I wouldn't like to recreate i= ndexes as >> it's not needed. > If it is only functions which retain their signature and only change th= e code, > there is no need to touch their related objects. You can CREATE OR REPL= ACE > those functions and change nothing else. I know that it works as long as a function doesn't change its return type= =2E I'd like to cover this case as well not to worry about it in the future. Henc= e I'm looking for a general method with the above assumptions. --AbhNZvurQGq9rKAmcHFQbBXQCmdmYydXb-- --9Y5HKFZ1s8EM8gwGV36LeG28IsaZ15jWz Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEE/bUwFm9Qs8vtm2934cEiWwsmpPAFAlpxxypfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEZE QjUzMDE2NkY1MEIzQ0JFRDlCNkY3N0UxQzEyMjVCMEIyNkE0RjAACgkQ4cEiWwsm pPD+BxAAqapC57vkIL9Mm2E6Q9CSYEv9IDISkB8OiNDk040OimjmvoEyxvGji0JP EF+Yyu56lqbWlDP+1V5UMGvrtBwnd9hHaft0FK+9UVPFs40AZYXZGsEgwW9VGMoC qMhMbKtegvUBIgkNHNGzfMUrilx/2FAGevT5xrI2CAzY7uY5LNWN7ArKKObSyViS C/7nXqfd19BGHuO0emgRQx6wtrbWgfUD1pJ6uQYPkXcTWITl8Pji5DsdZpQ+KwCT Mqs9wOKHUiG3hzeOM+9PX3CqbHlOtU+mPgh1Eg+ZIeVMFNff3AOB7G4JlL4mDa6N 9mBLWuSIIto248KMDezaA9jv2Nx5yonm6OAhonqdgg9HAVidOU1YsEPjp7lcC7EV G/dO1HPOZdRsD8Hd68dGxwPfLdcYPHQecPg/apTjKIgGzyZA/NH42VjQ8IYGjDf5 ZYZ8GZ6C7ZLSq1eUValmPCspZEJIo/l94QoB/iMqDPkN/Gwj1AcAqCHBvJvcKCpI YOChJqT5CsCkYaWYgj2i+JPLTowHZp5updDiEIoiDrgp/8mpvC6u487gM2RTDlD3 cIAxzeTFugXRz7PxqfBXiawMO7NAmAnf7sU/XN8yiYOarjD4JmjRALqbXeCtiS5z QnpxE4fOCd8YX3G/yyQO1BX60skg/qb7Ji8R9sOkzf4pxlQqtrw= =417B -----END PGP SIGNATURE----- --9Y5HKFZ1s8EM8gwGV36LeG28IsaZ15jWz--