clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 497152 fiddles created (9380 in the last week).

select version();
version
PostgreSQL 11.2 (Debian 11.2-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
 hidden batch(es)


CREATE TABLE IF NOT EXISTS valrng ( low int, high int ); CREATE TABLE IF NOT EXISTS vals ( val int );
 hidden batch(es)


INSERT INTO valrng VALUES (2,5),(7,8); INSERT INTO vals VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
2 rows affected
10 rows affected
 hidden batch(es)


EXPLAIN ANALYZE SELECT val FROM valrng AS vr, vals AS v WHERE vr.low <= v.val AND v.val <= vr.high;
QUERY PLAN
Nested Loop (cost=0.00..100926.25 rows=640333 width=4) (actual time=0.033..0.042 rows=6 loops=1)
Join Filter: ((vr.low <= v.val) AND (v.val <= vr.high))
Rows Removed by Join Filter: 14
-> Seq Scan on vals v (cost=0.00..35.50 rows=2550 width=4) (actual time=0.010..0.011 rows=10 loops=1)
-> Materialize (cost=0.00..43.90 rows=2260 width=8) (actual time=0.002..0.002 rows=2 loops=10)
-> Seq Scan on valrng vr (cost=0.00..32.60 rows=2260 width=8) (actual time=0.005..0.006 rows=2 loops=1)
Planning Time: 0.144 ms
Execution Time: 0.107 ms
 hidden batch(es)


SELECT val FROM valrng AS vr, vals AS v WHERE vr.low <= v.val AND v.val <= vr.high;
val
2
3
4
5
7
8
 hidden batch(es)