Derby
  1. Derby
  2. DERBY-3937

Select count(*) scans all the rows (and is therefore slow with big tables), is the amount of rows not available/known for example in index ?

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Store
    • Labels:
      None
    • Environment:
      Any
    • Bug behavior facts:
      Performance

      Description

      Create table with 5000000 rows. Create index on unique ID. Select count on such table is going to take quite some time.

      Shouldn't the index contain amount of indexed rows and the value taken from there ?

      Additionally, queries of the form select count from table where col1=value; take lots of time (depending on amount of rows satisfying WHERE clause) even if index on col1 exists. Isn't it possible to find first and last occurence in the index, and then calculate amount of rows more effectively then scanning through all of them ?

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Martin Hajduch
          • Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:

              Development