in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

About paging, get total record

Last post 05-12-2008 12:45 AM by SqlRanger. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 05-10-2008 3:15 AM

    About paging, get total record

    Is there a fast way to get total record size from a Table?

     I know the query:

    "select count(*) from MyTable"

    totalRecords = cmd.ExecuteScalar();

    would get the total record size, is there a faster way. Because the above code would look the whole table to calculate the total, am I correct.

    I'm trying to do paging, need the total record size. Is it possible to get the toal record and using LIMIT @offset, @pagesize at the same time, so I don't have to excute the cmd two times?

    Thanks

    John

  • 05-12-2008 12:45 AM In reply to

    Re: About paging, get total record

    As far as I know, there is no way to figure out in advance the number of rows returned by a query. However you can create a table like the following;

    CREATE TABLE TablesRowCount (TableName TEXT PRIMARY KEY, RowCount INTEGER) ;

    And maintain it using triggers to keep RowCount up to date. 

     

     

    Regards

    Jesús López

Page 1 of 1 (2 items)
Powered by Community Server (Commercial Edition), by Telligent Systems