add batch
remove batch
split batch
comment selection
show hidden batches
hide batch
highlight batch
db<>fiddle
Db2
Firebird
MariaDB
MySQL
Node.js
Oracle
Postgres
SQLite
SQL Server
TimescaleDB
YugabyteDB
Developer-C 11.1
3.0
4.0
10.2
10.3
10.4
10.5
10.6
10.7
10.8
10.9
5.5
5.6
5.7
8.0
18
11g Release 2
18c
21c
23c
8.4
9.3
9.4
9.5
9.6
10
11
12
13
14
15
16
3.8
3.16
3.27
3.39
2012
2014
2016
2017
2017 (Linux)
2019
2019 (Linux)
2022
2.11
2.6
2.8
2.18
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
Sakila
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
no sample DB
AdventureWorks
no sample DB
no sample DB
AdventureWorks
no sample DB
no sample DB
no sample DB
no sample DB
run
markdown
donate
feedback
about
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?
.
with cte as ( select 1 as id, 1 as chat_id,20 as person_id union all select 2,1,19 union all select 3,2,19 union all select 4,2,3 union all select 5,3,19 union all select 6,3,2 ) select t1.* from cte t1 where exists ( select 1 from cte t2 where t2.chat_id=t1.chat_id and person_id in (2,20) having count(distinct person_id)=2)
with cte as ( select 1 as id, 1 as chat_id,20 as person_id union all select 2,1,19 union all select 3,2,19 union all select 4,2,3 union all select 5,3,19 union all select 6,3,2 ) select chat_id from cte t2 where person_id in (2,20) group by chat_id having count(distinct person_id)=2