Is count(*) really expensive ?
        Posted  
        
            by Anil Namde
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Anil Namde
        
        
        
        Published on 2010-04-27T10:11:25Z
        Indexed on 
            2010/04/27
            12:23 UTC
        
        
        Read the original article
        Hit count: 245
        
I have a page where I have 4 tabs displaying 4 different reports based off different tables.
I obtain the row count of each table using a select count(*) from <table> query and display number of rows available in each table on the tabs. As a result, each page postback causes 5 count(*) queries to be executed (4 to get counts and 1 for pagination) and 1 query for getting the report content.
Now my question is: are count(*) queries really expensive -- should I keep the row counts (at least those that are displayed on the tab) in the view state of page instead of querying multiple times? 
How expensive are COUNT(*) queries ?
© Stack Overflow or respective owner