Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Facebook
Downloads
Home
>
mailing lists
How can the Aggregation move to the outer query - Mailing list pgsql-hackers
From
Andy Fan
Subject
How can the Aggregation move to the outer query
Date
May 25, 2021
13:28:40
Msg-id
CAKU4AWoGHOJ2+DxN4yHHMWH6fHXDG6099+ZW16A1WtcQWd=UsA@mail.gmail.com
Whole thread
Raw
Responses
Re: How can the Aggregation move to the outer query
List
pgsql-hackers
Tree view
My question can be demonstrated with the below example:
create table m1(a int, b int);
explain (costs off) select (select count(*) filter (
where true
) from m1 t1)
from m1 t2 where t2.b % 2 = 1;
QUERY PLAN
---------------------------------
Seq Scan on m1 t2
Filter: ((b % 2) = 1)
InitPlan 1 (returns $0)
-> Aggregate
-> Seq Scan on m1 t1
(5 rows)
The above is good to me. The aggregate is run in the subPlan/InitPlan.
explain (costs off) select (select count(*) filter (
where t2.b = 1
) from m1 t1)
from m1 t2 where t2.b % 2 = 1;
QUERY PLAN
-------------------------------
Aggregate
-> Seq Scan on m1 t2
Filter: ((b % 2) = 1)
SubPlan 1
-> Seq Scan on m1 t1
(5 rows)
This one is too confusing to me since the Aggregate happens
on t2 rather than t1. What happens here? Would this query
generate 1 row all the time like SELECT aggfunc(a) FROM t?
--
Best Regards
Andy Fan (
https://www.aliyun.com/
)
pgsql-hackers
by date:
Previous
From:
Bharath Rupireddy
Date:
25 May 2021, 13:21:09
Subject:
Re: Skipping logical replication transactions on subscriber side
Next
From:
Aleksander Alekseev
Date:
25 May 2021, 13:55:13
Subject:
Add ZSON extension to /contrib/
Есть вопросы? Напишите нам!
Соглашаюсь с условиями обработки персональных данных
I confirm that I have read and accepted PostgresPro’s
Privacy Policy
.
I agree to get Postgres Pro discount offers and other marketing communications.
✖
×
×
Everywhere
Documentation
Mailing list
List:
all lists
pgsql-general
pgsql-hackers
buildfarm-members
pgadmin-hackers
pgadmin-support
pgsql-admin
pgsql-advocacy
pgsql-announce
pgsql-benchmarks
pgsql-bugs
pgsql-chat
pgsql-cluster-hackers
pgsql-committers
pgsql-cygwin
pgsql-docs
pgsql-hackers-pitr
pgsql-hackers-win32
pgsql-interfaces
pgsql-jdbc
pgsql-jobs
pgsql-novice
pgsql-odbc
pgsql-patches
pgsql-performance
pgsql-php
pgsql-pkg-debian
pgsql-pkg-yum
pgsql-ports
pgsql-rrreviewers
pgsql-ru-general
pgsql-sql
pgsql-students
pgsql-testers
pgsql-translators
pgsql-www
psycopg
Period
anytime
within last day
within last week
within last month
within last 6 months
within last year
Sort by
date
reverse date
rank
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
By continuing to browse this website, you agree to the use of cookies. Go to
Privacy Policy
.
I accept cookies