cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henning von Bargen <H.vonBar...@Triestram-Partner.de>
Subject AW: AW: Esql:Question and Problem (Again)
Date Wed, 06 Dec 2000 08:38:23 GMT
> -----Urspr√ľngliche Nachricht-----
> Von:	Donald Ball [SMTP:balld@webslingerZ.com]
> Gesendet am:	Dienstag, 5. Dezember 2000 22:04
> An:	cocoon-users@xml.apache.org
> Betreff:	Re: AW: Esql:Question and Problem (Again)
> 
> On Tue, 5 Dec 2000, Henning von Bargen wrote:
> 
> > > On Mon, 4 Dec 2000, Robert Dale wrote:
> > >
> > > > <xsp:logic>
> > > > if (skipRows > 0)
> > > >   totalResults = esqlResults - skipRows;
> > > > else
> > > >   totalResults = esqlResults;
> > > > </xsp:logic>
> > > >
> > > >
> > > > However, sometimes there seems to be a conflict with generating the
> > > > <esql:get-tow-position/> code from the stylesheets so I have to
be
> > > > naughty and use _esql_query.position directly.
> > >
> > > how about this - i'll add an element
> > >
> > > <esql:get-row-count/>
> > >
> > > which may appear inside esql:results after esql:row-results, which
will
> > > return the total number of rows returned by the query (regardless of
the
> > > values of skip-rows and max-rows).
> > >
> > > - donald
> >
> > Hmm. Not a good idea IMHO.
> > Because it would require to fetch _all_ records.
> > This would blast cocoon if the query returns 100000 records, for
example.
> 
> how about this - i'll only iterate over the entire resultset to get the
> row-count if the author has asked for it?

Well, do it if you like. But I don't think that it is really needed,
because we could do select count(*) from ... where ...
Your proposal 
  works in a very general way,
  but requires the db to actually transmit all the records.
select count(*) 
  allows the db to use it's indexes, statistics and so on
  and transmit only one integer, so it will be MUCH faster for large tables.
You could even use it internally (later) to return the total number of rows
if has-more-rows is true. But then you'll have to parse the query and
replace
the columns-to-fetch-list with count(*).

> 
> > I would prefer to have these elements:
> > get-first-row-returned
> > 	gives the first returned row (zero-based) (so this is equal to
> > skip-rows)
> 
> how about get-skip-rows?
> 
> > get-last-row-returned
> > 	gives the last returned row (zero-based) (so this is a number in the
> > 	range skip-rows .. skip-rows + (max-rows - 1).
> 
> how about get-max-rows - and you can do the math? :)

To give an example of what I mean:
Say, we have 25 records in the DB table.
Now we execute the query with skip-rows=20 and max-rows=10.
The result will contain only the records (zero-base) 20 to 24.
My proposed get-last-row-returned would give the answer 24 and not 29.
has-more-rows returns false.
If the table had exactly 30 records, then the same statement gives the
results
get-last-row-returned = 29 and has-more-rows = false.
If the table had more than 30 records, then
get-last-row-returned = 29 and has-more-rows = true.

The name get-max-rows is ambigous, because
it sounds like it would return the value that I passed in as max-rows.
But what it means (if I understand your intention) is to return the number
of records
actually returned, which may be in the range 0 .. max-rows.

> 
> > has-more-rows
> > 	is true if there are more rows to display
> >  	(you only have to fetch one more row -internally- to set this
> > variable).
> 
> good idea.
> 
> - donald
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

Mime
View raw message