[BNM] best way to count a query string

Antony Jones antonyj at gamesys.co.uk
Thu Mar 2 14:01:45 GMT 2006


Use a DB, and use the string as the primary key. The second column in that table should be the number of times it was seen. Increased each time it is hit.

Otherwise, log all the strings regardless, and when you want to know how many were found, do a count(*) and group by the string.

The second insert query is faster to run.

Antony Jones
Developer
 
Gamesys Limited
e: antonyj at gamesys.co.uk
t: 0207 287 1571
a: 3rd Floor, 54-62 Regent Street, LONDON, W1B 5RE


> -----Original Message-----
> From: Josh Russell [mailto:joshbnm at gmail.com]
> Sent: 02 March 2006 13:32
> To: Brighton New Media
> Subject: [BNM] best way to count a query string
> 
> hello,
> 
> this is a slightly abstract question, and the answer will be limited
> some by the technology and expertise available to me, but here
> goes.......
> 
> 
> i have a url, for examples sake:
> 
> http://www.mydomain.com/index.htm?query1=aaaa&query2=wwww
> 
> this url changes frequently e.g.
> 
> http://www.mydomain.com/index.htm?query1=aaaa&query2=wwww
> http://www.mydomain.com/index.htm?query1=aaaa&query2=xxxx
> http://www.mydomain.com/index.htm?query1=aaaa&query2=yyyy
> http://www.mydomain.com/index.htm?query1=aaaa&query2=zzzz
> 
> or even:
> 
> http://www.mydomain.com/index.htm?query1=aaaa&query2=wwww
> http://www.mydomain.com/index.htm?query1=bbbb&query2=wwww
> http://www.mydomain.com/index.htm?query1=cccc&query2=wwww
> http://www.mydomain.com/index.htm?query1=dddd&query2=wwww
> 
> but not so often.
> 
> now my question is, how can i record and count all the different
> strings that may appear for query2? e.g.
> 
> 1. wwww
> 2. xxxx
> 3. yyyy
> 4. zzzz
> 
> and then how many times each one appears too..
> 
> i guess this could be done in logs somehow, but there are potentially
> millions of different strings..
> 
> 
> any ideas greatly appreciated!
> 
> 
> cheers
> 
> josh
> 
> 
> 
> 
> --
> Josh Russell
> www.joshrussell.com
> www.comicrelief.com
> www.makepovertyhistory.org
> www.metranet.co.uk
> 
> get some web hosting!
> http://tinyurl.com/zvblf
> 
> --
> 
> BNM info/subscription/archives: http://www.brightonnewmedia.org/
> 
> BNM archive search: http://www.roddis.org/bnm/search.php
> BNM Del.icio.us tag: http://del.icio.us/tag/bnm/
> BNM Flickr group: http://www.flickr.com/groups/bnm/
> 
> BNM powered by http://www.screen-play.net/



More information about the BNMList mailing list
BNMList is hosted by Screenlists, a Screen-Play.net service