I'll keep the scenario simple:
- There is an app, and there is a database.
- In the database, there is a table with a large amount of records
- I feed the app these records regularly
Now, one reload can imply some of these changes: i. New records in set ii. Updated records in set iii. Deleted records in set
Finally, for records that remain the same I can make use of a diferent process that works as much as 100 times faster than reading the table through ODBC.
Knowing this, I am trying to reduce the reloading time by using the ODBC as little as possible and midway through my algorithm I encounter a question that I have not been able to solve.
**How much faster is a select count(*) where [condition]
opposed to select columnName where [condition]
Why? Because just by reloading the new and updated records, I can calculate whether there have been deletions or not by counting records depending on [condition]. Then, if there have been deletions, I'll have to read from the database those that remain. Nornally, the amount of new and updated records will be a small portion of the whole set. If a count is considerably faster than a normal select, I might want to use it as a fast check, since deleting records is not a common activity.
count(*)
will be faster as it will only return a single row whereas the other query will return many rows