14.14.3. Discussion
The easiest way to find out how many rows a query will return is to
use the COUNT function in SQL. For example, take this query:
SELECT id,name FROM People WHERE Age > 30
To find out how many rows it will return, simply issue this query:
SELECT COUNT(*) FROM People WHERE Age > 30
If the database is so volatile that you're afraid the number of rows
will change between the COUNT query and the data-fetching query, your
best option is to fetch the data and then count rows yourself.
With some DBD modules, execute returns the number
of rows affected. This isn't portable and may change in the future.