View Single Post
  #8 (permalink)  
Old 10-01-2008, 08:11 PM
kgun's Avatar
kgun kgun is offline
WebProWorld 1,000+ Club
WebProWorld MVP
 
Join Date: May 2005
Location: Norway
Posts: 5,612
kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9kgun RepRank 9
Default Re: I am looking for a PHP algorithm/script

  1. If there is a unique (simple) formulae, your problem must be related to the magnitude of the problem, billions of IP's in a table column that can easily be transformed to decimal and easily back to dotted notation. Then you have some choices.
  2. Computation that can be done directly in the database, using SQL calculus (aggregations?) on the table rows / columns.
  3. Then there is no need for outputting data to a large array and use a PHP script to do the calculus.
  4. If you have to use a scripting solution, that array may be too big to load it directly into the computers memory.
  5. If it is too big you may split it into smaller manageable arrays. Once the results are there, the "results arrays" can be combined into a larger array and inserted into the database. May be the best is to use different databases for different countries / rigions with many IP tables and use the unique formula on each.
  6. Streaming solutions may also be an alternative, where data are read in chunks into the computers memory, transformed and inserted into the result database / tables.
  7. Personally if it is possible, I would have used 2, since you can do the math directly in the database.
Reply With Quote