On Jul 16, 2011, at 4:14 PM, - - wrote: > I would like to count rows in q whose mid does not exist in t.
I would write such a query like this: SELECT COUNT(*) FROM q LEFT OUTER JOIN t ON (t.mid = q.mid) WHERE t.mid IS NULL; And I would make sure there was an index on t.mid. (And for 9.2, as I understand it, q.mid as well, since I believe in 9.2 PostgreSQL will be able to compute the result strictly from the indexes without hitting the base tables.) -- Rick Genter rick.gen...@gmail.com