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 1scA1K-004TaA-LW for pgsql-general@arkaria.postgresql.org; Thu, 08 Aug 2024 20:46:02 +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 1scA1J-00GyVW-4N for pgsql-general@arkaria.postgresql.org; Thu, 08 Aug 2024 20:46:01 +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 1scA1I-00GyVO-PO for pgsql-general@lists.postgresql.org; Thu, 08 Aug 2024 20:46:00 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1scA1G-003lad-7B for pgsql-general@lists.postgresql.org; Thu, 08 Aug 2024 20:45:59 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ef2fccca2cso14731091fa.1 for ; Thu, 08 Aug 2024 13:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723149956; x=1723754756; 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=XZ5A3L96rkNOKGrk16ps+J2zmtYQgYVXxU8hjjRsRh8=; b=cSr6eFsCzolRHXLPTCmJaqRtsASWLQ9vfiPD/0lCQ9d5xjwk1UC2LF8kXqGQPpXUm3 IRagFKILyuripbj0IuwbkleGxiSgkLyggYGXWDIv76ajBSNb/2GZwIZJYrJwGM6qUNdB Wr6YVeOBv10jZS8Wk6XRFi5Yys3899N5c+eupE1Y65TjBCyq7d3uBhr5O9FMJOH40Zhh myaa2LmU+LQWqHUBAaqrDBfbHWJp0FaB2trxB24A7/cr8I5iWA0MTNw6y4gnOkoMRhUv q5599o+nHqU/xG9xr05fjxPjBLpHtvle1u8R9E/Aynpy3uRy9NZ/M4OhHLbWmp12Pddb kSQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723149956; x=1723754756; 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=XZ5A3L96rkNOKGrk16ps+J2zmtYQgYVXxU8hjjRsRh8=; b=YZGRRzNWnDG73C3hcb6geSRWkMj7ANjaPMbdSEdIDT+6KlY9ZDmzyr1NSxQI4c2WX6 tzKNFqLsLQPX+52ukJ2KbZtTgZwrkVCXwFC1cXy9ITNqO6fplC3hHJYNbxDLYXvCuJdW rXxk9SRx1Cvm8hKv7uU5K1LVixpROEif4rKxFYYFaMPrCgMzhDoIgWBic6/LSlfM7xxW /NbgwX3KKTLsRAP1HZCK7JSbvqe2emWnUoH/G8A+xZFrDVPtyU+fpK5hT9RZQZFaZ9PT zEb6kVBBPu1DSDOyxSHi/SdQqMmxvgI8lSC3yhqvGirsOoQNXciyv+ZfQwi0XhihhzQO BDxA== X-Gm-Message-State: AOJu0YwjWlO3pExfrEDWjuU+Y/SBZYKsu3RgAWyveEVFkIWvex45ZXZz EvS4hcEymq25I4oilPKVXcxxSDSFHoDKznSPCbKsVctjlk/zGZrdHVh+7rLj/fpVi4w0w1HFpWD qmPDl6gUbnPO508NcUVoNREdKlWR+VRu+GuA= X-Google-Smtp-Source: AGHT+IFN00/fqtCAA0yfpruPdDd/UdLgjoL84c0hWlnjvj0wpvV2+RFZevKIHKCXLFZPi/5J1R+EZGQfA9emOnxRY1Y= X-Received: by 2002:a2e:3c19:0:b0:2ec:1810:e50a with SMTP id 38308e7fff4ca-2f19de7214fmr21702581fa.32.1723149956024; Thu, 08 Aug 2024 13:45:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Thu, 8 Aug 2024 16:45:18 -0400 Message-ID: Subject: Re: Getting specific partition from the partition name To: veem v Cc: pgsql-general Content-Type: multipart/alternative; boundary="0000000000000610ea061f321dc0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000000610ea061f321dc0 Content-Type: text/plain; charset="UTF-8" YYYY_MM_DD is already setup for sorting, so just do: SELECT table_name FROM information_schema.tables WHERE table_name ~ 'table_part_p' ORDER BY 1 DESC; If you need to grab the numbers: SELECT substring('table_part_p2022_03_04' from '([\d_]+)$'); Cheers, Greg --0000000000000610ea061f321dc0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
YYYY_MM_DD is already setup for sorting, so just do:
<= br>
SELECT table_name FROM information_schema.tables WHERE table_= name ~ 'table_part_p' ORDER BY 1 DESC;

If you need to grab the numbers:

SELECT substring= ('table_part_p2022_03_04' from '([\d_]+)$');
=
Cheers,
Greg

--0000000000000610ea061f321dc0--