Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8O5i-003sHe-B0 for pgsql-admin@arkaria.postgresql.org; Tue, 05 Nov 2024 18:15:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t8O5f-00Gs8Q-9Z for pgsql-admin@arkaria.postgresql.org; Tue, 05 Nov 2024 18:15:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t8O5e-00Gs7G-Kj for pgsql-admin@lists.postgresql.org; Tue, 05 Nov 2024 18:15:43 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t8O5b-000LKZ-Pp for pgsql-admin@lists.postgresql.org; Tue, 05 Nov 2024 18:15:41 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3e5fee32e76so2641090b6e.1 for ; Tue, 05 Nov 2024 10:15:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crunchydata.com; s=google; t=1730830539; x=1731435339; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=P54DVL99MhLf/sstNvbGOJ2w03PAT+UbqTp954n1CGk=; b=dPQKgC3rrSazZOB/EZX8n8oVJUti2UidMvnp/xqsowscfFY9NteNmVY6x3RPhDx8ZE xSMrBs8V3X3U+QE4d2tGRdRDXo1LFoEU1p+3YjsSkoXg6Eb2ylCx5z9qCVe1gbeeJW2D UR67op2ehSTq04dQW0NAkmMUHe26Y/ohBS+7UCtYwnQsVfwr/in1haXJ7f5Bu1eEdAvE 8VNKxHMnYhlimDv28alSdlhzrSdiMy1wEMeS+zzQJbWPNnetGxMhj85Ub6BYQjEj5b8f renyRIjAV/SBDRNfcjTqjEvfdGo3PCgsBEr3m+5uekugPvhSanjD62+FNflbazovb5rD Qprw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730830539; x=1731435339; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P54DVL99MhLf/sstNvbGOJ2w03PAT+UbqTp954n1CGk=; b=hX0NqzBWQfl9P5GGkI85MeHIqFHFC56TYhvvGG/Js11Lg6Opsd5qH7UWWv9pPr0SnJ EeghyOvWbwqxt5XsdNaQDwD80puGV4EBprGcAXa2+AsZ/cBZIYBX5kMAI90dxflGcDXT 1wsO5j8VXOSnTca1mzaycWh0hbNIMUpIgMDdUPU61MHaDBoe2cs41ncumvvQzdT96bCr ALNdoL+lqfxMxvchTNEmktjsv4sAJRl7jcBErp7NtAfT4NWZIUyvp/0IPsCY8jXm6CWG +p55yA3hd1dk2mbJ3n+Vv69G8Ysn2r5k0cIxmBEYSYoVWboKVsWP8gcUpWWXBmkqKQ2e XUfQ== X-Forwarded-Encrypted: i=1; AJvYcCVZ+NAqKwqm7uTfP8MM1E8YGNkhFgz2QGAjnZO61NQX4NUAfmTCekn+GZEI/jwVpXXirtWGR0CmJdNCyw==@lists.postgresql.org X-Gm-Message-State: AOJu0YxlqQiRVvT3ElUme8xIS3QLqtE3MDOjfuXw2fu9ycUVsRYzOxIk YJm5x6RYvWm62XzTNOL8DETpzvQhP5Wk9T3QGdKo4IvEOobIo+Em2xGjP8ISbIUGkGmIiUNVOxY M5fgqPe7+OSZDUrb3yzAnz/BrW8OUfYQ9Ir0o9Q== X-Google-Smtp-Source: AGHT+IHKH/Z7uzmyfqmJHIKgomwMudW8CFlZtGGyJcZDkJ065RQvCR05wpn1Ci2+EH2ePUg4ZNeXED33a1lw0KDIgiI= X-Received: by 2002:a05:6808:1487:b0:3e0:4f6c:abcb with SMTP id 5614622812f47-3e758c4c75emr14760504b6e.28.1730830538603; Tue, 05 Nov 2024 10:15:38 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Keith Fiske Date: Tue, 5 Nov 2024 13:15:12 -0500 Message-ID: Subject: Re: PostgreSQL historical database To: Erik Serrano Cc: Samed YILDIRIM , Pgsql-admin , pgsql-admin Content-Type: multipart/alternative; boundary="0000000000006b9ab306262e6334" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000006b9ab306262e6334 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 5, 2024 at 12:30=E2=80=AFPM Erik Serrano = wrote: > > Dear Sirs, > > I'll tell you a little about what I need. Normally, during the day, > records are made or recorded in the main database, which at the end of th= e > day are consolidated (accounting closings) and are recorded in the > database. In order not to make the main database grow without measure > (which will only maintain the range between 3 months to 1 year). For this > reason, this data must be transferred to another database so that it last= s > over time and can be consulted by other areas. (This action is done human= ly > every day of the year at the end of the day) > Therefore, the project seeks to be able to carry out this extraction of > the consolidated data to another database, but automatically. > > I was thinking of doing this with some triggers or with jobs that allow m= e > to carry out these actions. I also thought of creating a replication of > only the consolidated tables to the new historical database server, but I > have not yet defined the method. > > That's why I need to know if there is a tool that allows me to create thi= s > database. > > I hope this clarifies a little the scope of the new historical database. > > Thank you very much in advance > Regards > > > *Erik R. Serrano Saavedra* > * Data Base Administrator* > > I would first recommend looking into partitioning for managing data retention like this. As Ron says, you'll want to look into the performance implications of this, but it allows for the most efficient method of removing old data from PostgreSQL and is typically worth the overhead costs. Otherwise you're dealing with potentially expensive deletion operations and managing bloat vs just detaching/dropping a table.