On 3/5/2016 7:15 PM, Paul Sanderson wrote: > So > > select count (*) from ... > > Doesn't require a crystal ball and returns the number of rows
It does however fail to satisfy "before I execute it in full" requirement. It essentially does execute the inner query in full, while counting the rows and discarding the actual data returned. > Select count(*) from ... Limit x This query doesn't mean what you think it means. LIMIT clause limits the number of rows in the resultset - which is pointless since the resultset in this case contains exactly one row. If you want to count the number of rows but stop at, say, 100, then you can transform your original statement like this: select count(*) from ( select original ... LIMIT 100 ); So, you append the LIMIT clause to the original query, then wrap the whole thing in another query that does the counting. -- Igor Tandetnik