Subject Re: [Firebird-Architect] Re: Cursors
Author David Jencks
On Saturday, June 5, 2004, at 11:16 PM, Alexander Klenin wrote:

>> From: David Jencks <david@...>
>> Well, it makes sense if he includes an order by clause.
>> But there is no way to determine the desired records in that case
>> other than determining at least the first 50,010 records. So, the
>> "first...skip" solution is as good as possible.
> Well, from the purely theoretical POV, if there is an
> index suitable for ordering, and this index is strored in
> a kind of balancd tree, then there should be possible to
> determine index value for Nth record in a logarithmic
> time. Whether this optimisation is useful enough is, of
> course, an entirely different question.
> ---

My understanding (which could be wrong) is that firebird indexes don't
tell you which transactions a particular record is visible in, so you
have to consult the set of back versions to determine for sure which
rows are the first 50,000.

I also don't see how a ordering by itself will help determine which is
the 50,000 record. Not every change in the tree will result in a
balancing operation affecting every node, so there are some
deletions/insertions that will not affect the path to the 50,000th
record. How do I find it's number without counting everything before
it or storing subtree counts in every node?

david jencks