By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
DROP TABLE IF EXISTS users_churn;
create table
users_churn(
id SERIAL PRIMARY KEY,
users varchar(10) not null,
dates timestamp
);
insert into users_churn(users, dates)
values
('1ab7', '2022-01-04 10:22'),
('1ab7', '2022-04-26 18:30'),
('1ab7', '2022-05-12 20:10'),
('1ab7', '2022-07-02 20:55'),
('3ac5', '2022-02-05 05:12'),
('3ac5', '2022-04-09 07:17'),
('3ac5', '2022-07-03 04:19');
7 rows affected
select * from users_churn
id | users | dates |
---|---|---|
1 | 1ab7 | 2022-01-04 10:22:00 |
2 | 1ab7 | 2022-04-26 18:30:00 |
3 | 1ab7 | 2022-05-12 20:10:00 |
4 | 1ab7 | 2022-07-02 20:55:00 |
5 | 3ac5 | 2022-02-05 05:12:00 |
6 | 3ac5 | 2022-04-09 07:17:00 |
7 | 3ac5 | 2022-07-03 04:19:00 |