↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / Versions

内联 WITH 查询 (公用表表达式)

Recorded source states and original language descriptions. Missing version evidence stays unknown.

The source snapshot records transitions for PostgreSQL 8.1–18. The historical matrix records independent cells for 7.4–18. Neither records support for PostgreSQL 19 or 20; newer versions remain unknown. These source claims are distinct from runtime measurements.

No translation of this description is recorded. The original Chinese description is shown. The source label is retained in Chinese; no translated label is recorded.

性能

Description

既非递归也没有任何副作用(例如 INSERT/UPDATE/DELETE)的 WITH 查询可以内联执行,从而带来性能改进。可以通过使用 "NOT MATERIALIZED" 子句强制对查询执行此行为,例如:

WITH cte AS NOT MATERIALIZED (
    SELECT * FROM a
)
SELECT * FROM cte
JOIN b ON b.id = cte.id;

更多信息请访问 https://www.postgresql.org/docs/12/queries-with.html

Selected version: PostgreSQL 18

No

20191817161514131211109.69.59.49.39.29.19.08.48.38.28.18.07.4
UnknownUnknownNoNoNoNoNoYesYesNoNoNoNoNoNoNoNoNoNoNoNoNoNoNo

Compare versions

Original documentation links

Related source snapshot entry · The original source supplies this relationship; each matrix retains its own states.

Complete source facts and provenance

legacy · center · a530e9d8fdd236976d54f98edbdcf39f8e14bd31bc2bb6162cd872d2a22f3e1a

{
  "Key": "321",
  "SourceKind": "legacy",
  "SourceDatabase": "center",
  "SourceTable": "featurematrix_feature",
  "SourceKey": "321",
  "SourceHash": "a530e9d8fdd236976d54f98edbdcf39f8e14bd31bc2bb6162cd872d2a22f3e1a",
  "Name": "内联 WITH 查询 (公用表表达式)",
  "NameLocale": "zh-Hans",
  "GroupKey": "1",
  "GroupName": "性能",
  "GroupLocale": "zh-Hans",
  "Ordinal": 0,
  "GroupOrder": 10,
  "Facts": {
    "featuredescription": "既非递归也没有任何副作用(例如 INSERT/UPDATE/DELETE)的 WITH 查询可以内联执行,从而带来性能改进。可以通过使用 \"NOT MATERIALIZED\" 子句强制对查询执行此行为,例如:\n\n```\nWITH cte AS NOT MATERIALIZED (\n    SELECT * FROM a\n)\nSELECT * FROM cte\nJOIN b ON b.id = cte.id;\n```\n\n更多信息请访问 [https://www.postgresql.org/docs/12/queries-with.html](https://www.postgresql.org/docs/12/queries-with.html)",
    "featurename": "内联 WITH 查询 (公用表表达式)",
    "group_id": 1,
    "id": 321,
    "v10": 0,
    "v11": 0,
    "v12": 1,
    "v13": 1,
    "v14": 0,
    "v15": 0,
    "v16": 0,
    "v17": 0,
    "v18": 0,
    "v74": 0,
    "v80": 0,
    "v81": 0,
    "v82": 0,
    "v83": 0,
    "v84": 0,
    "v90": 0,
    "v91": 0,
    "v92": 0,
    "v93": 0,
    "v94": 0,
    "v95": 0,
    "v96": 0
  },
  "Cells": [
    {
      "Version": "10",
      "State": "no",
      "EvidenceKind": "legacy-database:v10",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "11",
      "State": "no",
      "EvidenceKind": "legacy-database:v11",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "12",
      "State": "yes",
      "EvidenceKind": "legacy-database:v12",
      "TransitionVersion": "",
      "Supported": true,
      "Original": 1
    },
    {
      "Version": "13",
      "State": "yes",
      "EvidenceKind": "legacy-database:v13",
      "TransitionVersion": "",
      "Supported": true,
      "Original": 1
    },
    {
      "Version": "14",
      "State": "no",
      "EvidenceKind": "legacy-database:v14",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "15",
      "State": "no",
      "EvidenceKind": "legacy-database:v15",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "16",
      "State": "no",
      "EvidenceKind": "legacy-database:v16",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "17",
      "State": "no",
      "EvidenceKind": "legacy-database:v17",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "18",
      "State": "no",
      "EvidenceKind": "legacy-database:v18",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "7.4",
      "State": "no",
      "EvidenceKind": "legacy-database:v74",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "8.0",
      "State": "no",
      "EvidenceKind": "legacy-database:v80",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "8.1",
      "State": "no",
      "EvidenceKind": "legacy-database:v81",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "8.2",
      "State": "no",
      "EvidenceKind": "legacy-database:v82",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "8.3",
      "State": "no",
      "EvidenceKind": "legacy-database:v83",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "8.4",
      "State": "no",
      "EvidenceKind": "legacy-database:v84",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "9.0",
      "State": "no",
      "EvidenceKind": "legacy-database:v90",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "9.1",
      "State": "no",
      "EvidenceKind": "legacy-database:v91",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "9.2",
      "State": "no",
      "EvidenceKind": "legacy-database:v92",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "9.3",
      "State": "no",
      "EvidenceKind": "legacy-database:v93",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "9.4",
      "State": "no",
      "EvidenceKind": "legacy-database:v94",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "9.5",
      "State": "no",
      "EvidenceKind": "legacy-database:v95",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    },
    {
      "Version": "9.6",
      "State": "no",
      "EvidenceKind": "legacy-database:v96",
      "TransitionVersion": "",
      "Supported": false,
      "Original": 0
    }
  ],
  "Texts": [
    {
      "Locale": "zh-Hans",
      "Title": "内联 WITH 查询 (公用表表达式)",
      "BodyHTML": "\u003cp\u003e既非递归也没有任何副作用(例如 INSERT/UPDATE/DELETE)的 WITH 查询可以内联执行,从而带来性能改进。可以通过使用 \u0026#34;NOT MATERIALIZED\u0026#34; 子句强制对查询执行此行为,例如:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eWITH cte AS NOT MATERIALIZED (\n    SELECT * FROM a\n)\nSELECT * FROM cte\nJOIN b ON b.id = cte.id;\n\u003c/code\u003e\u003c/pre\u003e\n\u003cp\u003e更多信息请访问 \u003ca href=\"https://www.postgresql.org/docs/12/queries-with.html\" rel=\"nofollow\"\u003ehttps://www.postgresql.org/docs/12/queries-with.html\u003c/a\u003e\u003c/p\u003e\n",
      "SourceHash": "a530e9d8fdd236976d54f98edbdcf39f8e14bd31bc2bb6162cd872d2a22f3e1a",
      "ContentHash": "79b15445a9e0098c663415436419f09c9c2aa59a1307ab0548f1bb152d9e985c",
      "Payload": {
        "description": "既非递归也没有任何副作用(例如 INSERT/UPDATE/DELETE)的 WITH 查询可以内联执行,从而带来性能改进。可以通过使用 \"NOT MATERIALIZED\" 子句强制对查询执行此行为,例如:\n\n```\nWITH cte AS NOT MATERIALIZED (\n    SELECT * FROM a\n)\nSELECT * FROM cte\nJOIN b ON b.id = cte.id;\n```\n\n更多信息请访问 [https://www.postgresql.org/docs/12/queries-with.html](https://www.postgresql.org/docs/12/queries-with.html)",
        "name": "内联 WITH 查询 (公用表表达式)"
      }
    }
  ],
  "GroupTitles": {
    "zh-Hans": "性能"
  },
  "RelatedKey": "inlined-with-queries-common-table-expressions"
}

Complete source data JSON