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?.
create table users (id int, name varchar(10));
insert into users values (4,'Bill'),(6,'Joe'),(8,'Alex');
3 rows affected
SELECT *
FROM users
WHERE id IN (6, 8, 8);
id | name |
---|---|
6 | Joe |
8 | Alex |
SELECT u.id, u.name
FROM users AS u
JOIN (
SELECT 6 AS id
UNION ALL SELECT 8
UNION ALL SELECT 8) AS i
ON u.id = i.id
id | name |
---|---|
6 | Joe |
8 | Alex |
8 | Alex |