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 1vBewF-002Tuo-RH for pgsql-performance@arkaria.postgresql.org; Wed, 22 Oct 2025 19:56:03 +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 1vBewE-0010oq-8I for pgsql-performance@arkaria.postgresql.org; Wed, 22 Oct 2025 19:56:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vBewD-0010oi-U0 for pgsql-performance@lists.postgresql.org; Wed, 22 Oct 2025 19:56:00 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vBewA-003fX9-1Z for pgsql-performance@lists.postgresql.org; Wed, 22 Oct 2025 19:56:00 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-378d61ce75aso239051fa.1 for ; Wed, 22 Oct 2025 12:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761162957; x=1761767757; 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=2o2mO3Aak2M8ipoToXZyrzGd4Bbk4dz7FJ8oaR/cvFo=; b=GlUlZwyP1rvkZdwJlAXaE+Z+SRgKlF5KaquL/8rTfdwVhjNGQy59XmUEHr7yMRvL5j /DF2wEcTBitO6yFXZA5J4m8EF/x+SwUDuIoYo2qeeDcCNOvUQts4npijfs2+w5UNS6f8 KjOG/R4Jn5lmKx7b++uY66yUSj44z90UUNyGf3mIcDmlJf4Bkv5RcnV8p4BtttBzcD/w 2GfYrWw2rBj2WuNV8ftkV1+Q/X3dAxcbvTI+vcmL4lLja7ruOQmgDfzE/6lw3cJzNkzN 8R4UaAIDdennIPGJus/t54MmK9inLNYUNvspbvgiPvaSGr4M2evFAZinrMvSBSn62KaV jMhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761162957; x=1761767757; 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=2o2mO3Aak2M8ipoToXZyrzGd4Bbk4dz7FJ8oaR/cvFo=; b=JvVpot9l5yCnbc1ODmYaGZ753Yjo3qKHLEEyBm795S3oBJgqwuGOFa+tQ40Lwr1JgO fDhETTU5OnEStXQPnPF60gBVEasvxULnbdBTt5gWIqvjVIOaycHhNwPYQCxxwvdWzm3Q HBQjlH9Witjc0LN88pLm+4/rTcC91AWvXK9qGkThjHyPCQpV3eOaGsvYm7SRruuKUyJx ZTPaWimY843cRG73lWznyWSLZtpEh4pVw/IJ4IhvkVWMRU0AK7eCebVxkqGSJ7KtMIve AHHY1RzCv6vETouVywW4s59dvTv9v8Job83h1YOHrpDF1iClqbMkKGVh6fWizhoELkim RwUg== X-Gm-Message-State: AOJu0Yzpcn8m2Amc6Ezqv6nibCCNpJWc845ydb0ihq1dwgXhyO9/wJdr WQdN4WK3+3NqHS2mYHyscp8OulK48dRlB1z1BHC4F8s07CXXSi7I3WHYjPwdguJSY2/e4Yu1RKg FeGa4zLoBG/bPztIqgHxPXNcpHX4iyYI= X-Gm-Gg: ASbGncv2XWCjua4Wrd0QVDN86fohR2kmLp4BcRgMXJj+o0EFUBCGV+Zswt0AWC1Q0XN zHh9SY3miMnLun+CFhzTpYUIDzdMmT7znCQ4uCRDjRAUBpjIJUcvwGpiFiuCA+TNFT9h1wfLYfk C91gzWabDsonSjR0bFvdIXVTUIyg36x0zCd6G+i6mHqZbC6ZEH0eVcbZewnsbiexiPL8GVHakUr 8ylBGlO/2yPOAHbS5DIAhEJBja+kSahNwaWn6LJpMNy5p703JxtMj2YtGfsYJZ9AV5x1+gkld8m cWfEH54zeLaQ1U83bqM8xJF6LjrwsfJJXLv+JeABFlYNk/GfcW8= X-Google-Smtp-Source: AGHT+IHYvVB0ARDBR4hRdcSPh8BTgq+CKT/PF0v7JoHjx/JdbSiAK+piktZwmxiv4fXGRl90bBH/r9du83drPbPLSVM= X-Received: by 2002:a2e:b889:0:b0:376:4320:e35a with SMTP id 38308e7fff4ca-378c0e36ab2mr15902761fa.23.1761162957122; Wed, 22 Oct 2025 12:55:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Thu, 23 Oct 2025 08:55:45 +1300 X-Gm-Features: AS18NWBlttCljrAgbUDVQpZjckQ91x7-cZ3CIHa_vJ9emFC7sLuQE5EoCAgKXB8 Message-ID: Subject: Re: Performance implications of partitioning by UUIDv7 range in PostgreSQL v18 To: Jonathan Reis Cc: pgsql-performance@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 22 Oct 2025 at 23:53, Jonathan Reis wrote: > Will the planner efficiently prune partitions when queries filter by UUIDv7 ranges (e.g., WHERE id BETWEEN uuidv7_floor(timestamp1) AND uuidv7_floor(timestamp2) that align with time periods? It depends. What are timestamp1 and timestamp2? If they're constants, then the planner can prune away tables outside of the given range as you're partitioning by range (id). Don't expect any pruning if you were to do something like uuid_extract_timestamp(id) when partitioned by "id". The function is just a blackbox to the pruning code. If timestamp1 and timestamp2 are columns from another table, then the planner won't do any pruning (the executor might). It should be trivial to mock up some tables and look at EXPLAIN to see what the planner can and can't do for pruning. Just keep in mind the executor also can prune both during executor startup, which is the first opportunity to know the results of stable functions (such as NOW()) and external parameter values (for PREPARE statements). Pruning can also occur during execution as parameter values being used in clauses containing the partition key in Append/MergeAppend change. More details about that in: https://www.postgresql.org/docs/current/ddl-partitioning.html#DDL-PARTITION-PRUNING David