Những điều kỳ lạ của Bộ lập kế hoạch Postgres: Sắp xếp tăng dần và khi nó gặp sự cố

Tác giả: pganalyze
Ngày xuất bản: 2024-10-02T00:00:00
Length: 07:30

Tóm tắt nội dung

Mô tả

*Find the article on our blog here:*

https://pganalyze.com/blog/5mins-postgres-incremental-sort

In E120 of "5mins of Postgres" we return to our Postgres planner quirks series to talk about Incremental Sort, and when it goes wrong. Incremental Sort can often speed up query plans when you have an existing sort order; however, there can be edge cases where the planner chooses a sub-optimal plan.

*Learn more about pganalyze:*

https://pganalyze.com

https://pganalyze.com/newsletter

https://www.linkedin.com/company/pganalyze

*Check out the pganalyze library for eBooks, webinars, and more:*

https://pganalyze.com/resources

📑 *What we have discussed in this episode of 5mins of Postgres:*

*"Implement Incremental Sort" commit by Tomas Vondra in Postgres 13*

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=d2d8a229bc58a2014dce1c7a4fcdb6c5ab9fb8da

*"Incremental Sort" node in EXPLAIN output*

https://pganalyze.com/docs/explain/other-nodes/incremental-sort

*5mins of Postgres - Faster query plans with Postgres 16: Incremental Sorts, Anti-JOINs and more*

https://pganalyze.com/blog/5mins-postgres-16-faster-query-plans

*"Planner chooses incremental [sort] but not the best [index]" discussion on pgsql-hackers*

https://www.postgresql.org/message-id/flat/d2f06ddc-a8d4-48ea-893b-a95255c632b9%40loxodata.com

*"estimate_num_groups" function in Postgres*

https://github.com/postgres/postgres/blob/db0c96cc18aec417101e37e59fcc53d4bf647915/src/backend/utils/adt/selfuncs.c#L3416

*"Add enable_presorted_aggregate GUC" commit by David Rowley in Postgres 16*

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=3226f47282a05979483475d1e4a11aab8c1bfc39

*"Add proper planner support for ORDER BY / DISTINCT aggregates" discussion on pgsql-hackers*

https://www.postgresql.org/message-id/flat/CAApHDvpHzfo92%3DR4W0%2BxVua3BUYCKMckWAmo-2t_KiXN-wYH%3Dw%40mail.gmail.com)

#postgres #postgresql #queryoptimization

Dịch Vào Lúc: 2025-08-15T13:27:03Z

Yêu cầu dịch (Một bản dịch khoảng 5 phút)

Phiên bản 3 (ổn định)

Tối ưu hóa cho một người nói. Phù hợp cho video chia sẻ kiến thức hoặc giảng dạy.

Video Đề Xuất