Combining with SQL
Use jev() as a normal predicate: indexes first, then joins, views, and GROUP BY.
jev() is a boolean. Put cheap, indexed predicates first so fewer rows reach the model.
sql
SELECT * FROM tickets
WHERE status = 'open'
AND jev(tickets, 'the customer is angry');It joins like any other function. The row you pass still needs a real table or view type so the read-ahead can batch it; see How it works.
sql
SELECT c.name, t.subject
FROM tickets t
JOIN customers c ON c.id = t.customer_id
WHERE jev(t, 'this is a billing dispute');Drop columns the model should not see. A view is easier to reuse than a nested SELECT:
sql
CREATE VIEW ticket_for_jev AS
SELECT id, subject, body FROM tickets;
SELECT * FROM ticket_for_jev v
WHERE jev(v, 'the customer threatens legal action');GROUP BY works on jev_choice() (or anything else you select):
sql
SELECT jev_choice(tickets, 'which team should handle this?',
ARRAY['billing', 'technical', 'security', 'sales']) AS team,
count(*)
FROM tickets
GROUP BY 1;Subqueries and CTEs that expose an anonymous record cannot be read ahead and cost one request per row. Prefer a base table or a view. For wide scans, Large tables.