Re: Multithreading of [replace]

This WebDNA talk-list message is from

1999


It keeps the original formatting.
numero = 23106
interpreted = N
texte = >>Given that I have written a database to do logging of visitors to the website, >>so that I can do my own analysis of who did what, I am running into a problem >>with the sheer number of write commands being issued to this database > >>[search db=carts.db&eqCARTdata=[cart]&DATEtype=date&DATEsort=1&DATEsdir=de] >>[showif [numfound]=0] >>[Append db=carts.db] >>cart=[cart]&date=[date]&firstpage=[thisurl]&lastpage=[thisurl] >>[/append] >>[/showif] >>[showif [numfound]=1] >>[replace db=carts.db&eqCARTdata=[cart]] >>lastpage=[thisurl] >>[/replace] >>[/showif] >>[/search] > >>So, Grant, here is my question: Is there anything that can be optimized that >>will alleviate the speed hit this code causes under load? > >Date searching can be very slow compared to plain text, because WebCatalog >must interpret those dates and calculate lots of stuff. I would re-order >your date text into YYYY/MM/DD order so that it is text-sortable *without* >needing to specify DATEtype=date. I would also set allCase=T so searches >and replaces are case-sensitive (a bit faster). > >Finally, you can get rid of that whole ShowIf thing: unless I misunderstand >your intention, we already put a feature into replace that will append if >not found: [replace db=xx&append=T] will append a new record if none is >found. Hi Brian, Grant may have missed the fact that if you get rid of those showif's and use a straightforward [replace append=t] context, webcat will overwrite your 'firstpage value when it performs a replace. So you would have to modify your replace parameters as I've shown below ...Another suggestion to speed things up, assuming you wish to continue using a search context, would be to remove those date sort parameters. They only slow things down, and you do not need them unless you are displaying results, which you are not.Now that I've made all these comments, I have an even faster solution. The fact of the matter is that you don't need the search context at all. Therefore I would get rid of it completely. You can perform the same tasks shown above with a single replace and a single lookup, like this:[replace append=t&db=carts.db&eqCARTdata=[cart]&allcase=t]cart=[cart]&date=[date %Y/%m/%d]&firstpage=[lookup db=carts.db&value=[cart]&lookinfield=cart&returnfield=firstpage¬found=[thisurl]] ]&lastpage=[thisurl][/replace]Sincerely, Ken Grome Associated Messages, from the most recent to the oldest:

    
  1. Re: Multithreading of [replace] (Kenneth Grome 1999)
  2. Re: Multithreading of [replace] (Christer Olsson 1999)
  3. Re: Multithreading of [replace] (Kenneth Grome 1999)
  4. Re: Multithreading of [replace] (Brian B. Burton 1999)
  5. Re: Multithreading of [replace] (Grant Hulbert 1999)
  6. RE: Multithreading of [replace] (Olin Lagon 1999)
  7. Re: Multithreading of [replace] (Brian B. Burton 1999)
  8. RE: Multithreading of [replace] (Olin Lagon 1999)
  9. Multithreading of [replace] (Brian B. Burton 1999)
>>Given that I have written a database to do logging of visitors to the website, >>so that I can do my own analysis of who did what, I am running into a problem >>with the sheer number of write commands being issued to this database > >>[search db=carts.db&eqCARTdata=[cart]&DATEtype=date&DATEsort=1&DATEsdir=de] >>[showif [numfound]=0] >>[Append db=carts.db] >>cart=[cart]&date=[date]&firstpage=[thisurl]&lastpage=[thisurl] >>[/append] >>[/showif] >>[showif [numfound]=1] >>[replace db=carts.db&eqCARTdata=[cart]] >>lastpage=[thisurl] >>[/replace] >>[/showif] >>[/search] > >>So, Grant, here is my question: Is there anything that can be optimized that >>will alleviate the speed hit this code causes under load? > >Date searching can be very slow compared to plain text, because WebCatalog >must interpret those dates and calculate lots of stuff. I would re-order >your date text into YYYY/MM/DD order so that it is text-sortable *without* >needing to specify DATEtype=date. I would also set allCase=T so searches >and replaces are case-sensitive (a bit faster). > >Finally, you can get rid of that whole ShowIf thing: unless I misunderstand >your intention, we already put a feature into replace that will append if >not found: [replace db=xx&append=T] will append a new record if none is >found. Hi Brian, Grant may have missed the fact that if you get rid of those showif's and use a straightforward [replace append=t] context, webcat will overwrite your 'firstpage value when it performs a replace. So you would have to modify your replace parameters as I've shown below ...Another suggestion to speed things up, assuming you wish to continue using a search context, would be to remove those date sort parameters. They only slow things down, and you do not need them unless you are displaying results, which you are not.Now that I've made all these comments, I have an even faster solution. The fact of the matter is that you don't need the search context at all. Therefore I would get rid of it completely. You can perform the same tasks shown above with a single replace and a single lookup, like this:[replace append=t&db=carts.db&eqCARTdata=[cart]&allcase=t]cart=[cart]&date=[date %Y/%m/%d]&firstpage=[lookup db=carts.db&value=[cart]&lookinfield=cart&returnfield=firstpage¬found=[thisurl]] ]&lastpage=[thisurl][/replace]Sincerely, Ken Grome Kenneth Grome

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

carriage returns in data (1997) newbie question about zip code search (2003) WebCat2_Mac RETURNs in .db (1997) ShipCost and TaxRate problems (1998) Hiding a subsection of text (2002) Still having math problems (1997) WebCat2b13MacPlugIn - [showif][search][/showif] (1997) Why doesn't it change? (1998) Problems with [Applescript] (1997) Pithy questions on webcommerce & siteedit (1997) RAM variables (1997) taxRate is fine but taxTotal isn't (1997) WebCat2b13MacPlugIn - More limits on [include] (1997) Problems with [Search] param - Mac Plugin b15 (1997) WYSIWYG Editor? (2006) Math inside [showif] (1998) color (1999) [applescript] (1999) Upgrading old WebCat Database Files (1997) So [OT] it's not even funny (2003)