When doing a count (aggregate) SQL query, what can speed up the execution time in these 3 database systems? I'm sure many things could speed it up (hardware for one), but I'm just a novice DBA, so I'm sure I'll be getting a few answers here. I migrated about 157 million rows to a SQL Server database, and this query is taking forever. But in my source Netezza database, it takes seconds.
For example:
Netezza 6:
SELECT COUNT(*) FROM DATABASENAME..MYTABLE
Oracle 11g:
SELECT COUNT(*) FROM MYTABLE
SQL Server 2012:
SELECT COUNT(*) FROM DATABASENAME.[dbo].[MYTABLE]
Best Answer
Netezza is an appliance that is designed to excel at large table scans, so that's why you're getting such fast results on that system.
For your SQL Server, you can greatly speed up the row count by querying from the sys.dm_db_partition_stats DMV.
In a high transaction environment, this DMV is not guaranteed to be 100% accurate. But from your question, it sounds like you are just doing row counts to verify each table after your migration, so this query should work for you.