On Friday 31 January 2003 8:40 am, Wankyu Choi wrote:
On Friday 31 January 2003 7:17 am, Wankyu Choi wrote:
--- code excerpt from NeoBoard ---
def getArticles(...):
... prepare....
articles = [article for article in board.ZopeFind( obj_metatypes='NeoBoard Article' , search_sub=1)]
# I use ZopeFind instead of objectValues since articles get nested
...sort articles... ...return articles...
---------------------------
Note that my python/zope experience is limited. I'm still learning :-)
Suppose the 'board' folderish object ( let's assume it's a BTreeFolder; if it's present NeoBoard uses BTreeFolder2, otherwise Zope Folder ) holds about 10,000 articles.
Whenever a list of articles gets displayed, this statement should be executed. Most RDBMS-based boards do the same with a select/limit combo like the PHP NeoBoard does:
"SELECT article_field_list from board limit start_num, end_num"
Am I missing something?
Yes. Your SQL approach will access only the 50 relevent articles. The other 9950 stay untouched on disk. Your ZODB approach loads all 10000 into memory, then your presentation logic (I guess) ignores 99.5% of them.
Is there a way in Zope to limit the returned results as a limit clause would do in an SQL statement?
The best approach is to use ZCatalog. ZCatalog means you only need to load the articles into memory when you need them. -- Toby Dickenson http://www.geminidataloggers.com/people/tdickenson