Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-1980

Using primary key in select count()

    Details

    • Type: Feature Request
    • Status: Closed (View Workflow)
    • Priority: Optional
    • Resolution: Rejected
    • Affects Version/s: 1.2.1.GA
    • Fix Version/s: None
    • Component/s: Tools
    • Labels:
      None
    • Environment:

      JBoss Seam with MSSQL database connections

      Description

      I see in my JBoss log several lines like

      Hibernate: select count as col_0_0_ from ....

      I'm not sure how it's handled in mysql, oracle or other databases, but in mssql, indexes are stored in different datapages.
      When counting rows, if we use select count (primarykey), we scan a much lower number of pages than we currently do with select
      Example : if one row has a 4 bytes long primary key, and one row stores 1000 bytes,
      if the table has 20000 rows, sql will store this table in 2500 datapages (one page stores 8096 bytes).

      a select will scan the 2500 datapages, when a select (primarykey) will scan 1 (one) datapage.

      As you can see, the impact on database server can be important for large tables with a lot of rows.

      Rgds

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  taccart Thierry
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 1 day
                    1d
                    Remaining:
                    Remaining Estimate - 1 day
                    1d
                    Logged:
                    Time Spent - Not Specified
                    Not Specified