Subject | Re: [firebird-support] How do I read a specific range of records from a table in the database |
---|---|
Author | Ann Harrison |
Post date | 2013-01-21T20:45:54Z |
On Mon, Jan 21, 2013 at 2:59 PM, HotRodRudy <rpopeszku@...> wrote:
tables and conditions>
way to say SELECT COUNT(*) FROM SURFACE, but Firebird almost certainly does
the necessary transformation.
10%?) in a table, I guess you could start by reading all of them, dividing
the count by 10 and then reading only that number, but that's a very
inefficient way to handle the problem.
If you know that you want 50 or 100 records, fine, ask for that many, but
ask for them sorted by some field so you have a change of knowing which
records you're getting.
Good luck,
Ann
[Non-text portions of this message have been removed]
> Support,You can using something like SELECT FIRST <n> <field list> FROM <source
>
> I am using Firebird server 2.5.2, Windows 7, and Visual Basic 2010.
>
> I would like to read a certain # of records from a table in the database
> using a start / stop record range. I am trying to re-write an application
> written by someone else which reads the entire database from beginning to
> end which takes a long time and I may only need the last 1000 records of a
> database that can have over 100,000.
>
tables and conditions>
>That's going to read every record in the database. It's also a very odd
> I have been using the following to determine the total number of records
> in the database so I should be able to use it to establish a range.
>
> 'Find the total number of records in the SURFACE table
> Dim count As FbCommand = New FbCommand("SELECT COUNT(*) FROM ( select *
> from SURFACE )", fbc)
>
way to say SELECT COUNT(*) FROM SURFACE, but Firebird almost certainly does
the necessary transformation.
> Dim readCount As FbDataReader = count.ExecuteReaderIf you're trying to do something like reading 10% of the records (which
> readCount.Read()
> lastDbRecord = readCount.GetValue(0) ' Get the total number of records in
> this database
>
>
10%?) in a table, I guess you could start by reading all of them, dividing
the count by 10 and then reading only that number, but that's a very
inefficient way to handle the problem.
If you know that you want 50 or 100 records, fine, ask for that many, but
ask for them sorted by some field so you have a change of knowing which
records you're getting.
Good luck,
Ann
[Non-text portions of this message have been removed]