[Zope-DB] Z SQL equivelant of MySQL's SQL_CALC_FOUND_ROWS?
Chris Withers
chris at simplistix.co.uk
Mon Dec 5 02:42:09 EST 2005
Charlie Clark wrote:
>>>SELECT count(attribute) FROM relatiin WHERE condition
>>
>>Ah, okay, now I gotcha...
>>
>>>only returns 1 result so it's independent of LIMIT and result sets.
>>
>>I wonder how the two methods compare efficiency-wise?
Yes, well, we're talking about MySQL specifically ;-)
> Maybe although I sometimes why MySQL does anything: the documentation seems
> to imply that many decisions were sort of "let's do it like this": cf.
> particularly the recommendations for writing queries with JOINs. Personally I
> do not see it as valid SQL to predicate a query on "what was just asked".
Sorry, not a lot of this paragraph made sense :-S
> Regarding the original question: if I know I am working with LIMITs or result
> sets then this implies I don't want to know the total size of the results
> beyound len(results).
Not so. Think of batches:
"Now showing Results 5 - 10 of 25"
But why not just return all the rows and only show 5 of them?
"Now showing Results 5 - 10 of 250000"
;-)
Yes, it'll likely be a slower query anyway, but I can assure you, Zope
turning each of those rows into a Result object will be a LOT slower...
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope-DB
mailing list