vždy používají indexy
SELECT * FROM table
JOIN another_table ON table.geom && another_table.geom
AND another_table.name = 'Jihomoravsk'
SELECT k1.* FROM kraje AS k1
JOIN kraje AS k2 ON k1.geom |>> k2.geom
WHERE k2."NAZEV" = 'Jihomoravský';
SELECT o.* FROM kraje AS k
JOIN okresy AS o ON o.geom @ k.geom
WHERE k."NAZEV" = 'Jihomoravský';
SELECT k1.* FROM kraje AS k1
JOIN kraje AS k2 ON ST_Touches(k1.geom, k2.geom)
WHERE k2."NAZEV" = 'Jihomoravský';
SELECT k1."NAZEV", COUNT(k2."NAZEV")AS sousedi FROM kraje AS k1
JOIN kraje AS k2 ON ST_Touches(k1.geom,k2.geom)
GROUP BY k1."NAZEV"
ORDER BY sousedi DESC
SELECT p1.*, ST_Distance(p1.geom::geography, p2.geom::geography) AS vzdalenost FROM places AS p1
CROSS JOIN places AS p2
WHERE p2.name = 'Brno'
AND ST_Distance(p1.geom::geography, p2.geom::geography) > 0
AND p1.population > 10000
ORDER BY vzdalenost
LIMIT 10;
SELECT b.zastavba, o.brno_mesto, ((b.zastavba * 100) / o.brno_mesto ) AS procento FROM
(SELECT SUM(ST_Area(b.geom::geography)/1000000) AS zastavba FROM buildings_bm AS b) AS b,
(SELECT SUM(ST_Area(o.geom::geography)/1000000) AS brno_mesto FROM okresy AS o WHERE o."NAZEV" = 'Brno-město') AS o;
SELECT o.* FROM okresy AS o
JOIN waterways AS w ON ST_Intersects(o.geom, w.geom)
WHERE w.name = 'Litava';