<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8828652504552320257</id><updated>2011-07-02T01:23:51.976-07:00</updated><category term='theories'/><category term='mysql'/><category term='efficiency'/><category term='class'/><title type='text'>Cale's Technology Blog</title><subtitle type='html'>This is my blog about everything technology related in my life.  It focuses mostly on my PHP/Web Development career.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://caleorosz.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8828652504552320257/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://caleorosz.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>elacdude</name><uri>http://www.blogger.com/profile/04031211595081805191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_0w-fuejUVus/SQtuNfK0E0I/AAAAAAAABU8/48VGaMSbIrI/S220/cale_sm.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8828652504552320257.post-5756503559235868501</id><published>2008-11-04T22:23:00.000-08:00</published><updated>2008-11-05T11:49:56.886-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='class'/><title type='text'>My PHP Date and Time Calculator Class</title><content type='html'>&lt;center&gt;&lt;a href="http://www.elacdude.com/code/date_time_calculator/" target="_blank"&gt;&lt;img src="http://www.elacdude.com/code/date_time_calculator/exampleshot.gif" border="0" /&gt;&lt;/a&gt;&lt;/center&gt;
&lt;br /&gt;&lt;br /&gt;
This is a very unique class. It takes a date/time and adds or subtracts any units of time to it, then returns the value. It's very useful for memberships. For example, If you want to sell 30 day subscriptions on your site, you can use this script to calculate the expiration date of the subscription.
&lt;br /&gt;&lt;br /&gt;
An example of how this class can be found here: &lt;a href="http://www.elacdude.com/code/date_time_calculator/" target="_blank"&gt;http://www.elacdude.com/code/date_time_calculator/&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
There are hundreds of php date/time calculators, but this one works differently than any I've seen. It allows you to supply a date/time in many customizable formats. It also lets you supply date/times without leading zeros. For example a date such as: '4/25/08' normally would be unacceptable, but this class can successfully parse it. It will calculate leap years, different number of days in each month, roll over to the nexy month or year if necessary.
&lt;br /&gt;&lt;br /&gt;
My goal when writing this class was to make it as flexible as possible. I was sick of using classes that only accept dates in 1 format or classes that require you to supply dates/times with leading zeros. Simply supply the date and the format that it is in using the PHP style date/time modifiers. This way it allows you to supply dates in custom formats. You aren't stuck using a format like 2008-04-25. You can use a format like 'Friday, Oct 4th, 2008 4:42pm' if you'd like.
&lt;br /&gt;&lt;br /&gt;
The only problem with allowing date/times without leading zeros is if the numbers are bunched together, it can't read it properly (but neither can a human). For example, the class would read a date like '119' with a mask of 'nj' as 'November 9th', not 'January 19th'. But it is smart, if you supply a date like '219' with a mask of 'nj', it knows there's no such month as '21', so it defaults to 'February 19th", which is corrent.
&lt;br /&gt;&lt;br /&gt;
The list of currently supported date/time modifiers can be found here: &lt;a href="http://www.elacdude.com/code/date_time_calculator/date_time_formats.html" target="_blank"&gt;http://www.elacdude.com/code/date_time_calculator/date_time_formats.html&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
When you add units of time, simply supply the unit of time in the format of a string.
&lt;br /&gt;
For example, all of the below would return the same result:
&lt;br /&gt;
$obj-&gt;add("second", 30);&lt;br /&gt;
$obj-&gt;add("seconds", 30);&lt;br /&gt;
$obj-&gt;add("sec", 30);&lt;br /&gt;
$obj-&gt;add("sec.", 30);&lt;br /&gt;
$obj-&gt;add("secs", 30);&lt;br /&gt;
$obj-&gt;add("secs.", 30);&lt;br /&gt;
$obj-&gt;add("s", 30);&lt;br /&gt;
$obj-&gt;add("s.", 30);&lt;br /&gt;

&lt;br /&gt;
&lt;strong&gt;&lt;span style="font-size:130%;"&gt;Example usage of this class:&lt;/span&gt;&lt;/strong&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;font color="#000000" size="2" face="Verdana"&gt;&lt;font color="#0000FF"&gt;&amp;lt;?php&lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;=&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#7F007F"&gt;&lt;i&gt;new&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt; 
  Date_Time_Calc&lt;/font&gt;(&lt;font color="#007F00"&gt;"11/1/2008 17:40:00"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#007F00"&gt;"n/j/Y H:i:s"&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#7F007F"&gt;&lt;i&gt;echo&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;add&lt;/font&gt;(&lt;font color="#007F00"&gt;"mo"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;15&lt;/font&gt;);&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//you 
  may echo the return value of add() or subtract()&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//outputs: 
  2/1/2010 17:40:00&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;=&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#7F007F"&gt;&lt;i&gt;new&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt; 
  Date_Time_Calc&lt;/font&gt;(&lt;font color="#007F00"&gt;"11/20/2005 
  07:40:00 PM"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#007F00"&gt;"m/d/Y h:i:s A"&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;subtract&lt;/font&gt;(&lt;font color="#007F00"&gt;"hours"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;36&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#7F007F"&gt;&lt;i&gt;echo&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;date_time&lt;/font&gt;;&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//or 
  you can call add() or subtract() and echo the public $date_time variable&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//outputs: 
  11/22/2005 07:40:00 AM&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;=&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#7F007F"&gt;&lt;i&gt;new&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt; 
  Date_Time_Calc&lt;/font&gt;(&lt;font color="#007F00"&gt;"11/20/2005 
  07:40:00 PM"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#007F00"&gt;"m/d/Y h:i:s A"&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;calculate&lt;/font&gt;(&lt;font color="#007F00"&gt;"h"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;36&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#007F00"&gt;"subtract"&lt;/font&gt;);&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//you 
  can use calculate() instead of add() or subtract()&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;font color="#7F007F"&gt;&lt;i&gt;echo&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;date_time&lt;/font&gt;;&lt;br /&gt;
  &lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//outputs: 
  11/19/2005 07:40:00 AM&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;=&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#7F007F"&gt;&lt;i&gt;new&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt; 
  Date_Time_Calc&lt;/font&gt;(&lt;font color="#007F00"&gt;"Dec 
  5th, '08 08:05 am"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#007F00"&gt;"M jS, 'y h:i a"&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;add&lt;/font&gt;(&lt;font color="#007F00"&gt;"i"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;90&lt;/font&gt;);&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//you 
  may do multiple calculations one after another&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;add&lt;/font&gt;(&lt;font color="#007F00"&gt;"m"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;3&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;add&lt;/font&gt;(&lt;font color="#007F00"&gt;"y"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;1&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#7F007F"&gt;&lt;i&gt;echo&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;date_time&lt;/font&gt;;&lt;br /&gt;
  &lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//outputs: 
  Mar 5th, '10 09:35 am&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;=&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#7F007F"&gt;&lt;i&gt;new&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt; 
  Date_Time_Calc&lt;/font&gt;(&lt;font color="#007F00"&gt;"219"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#007F00"&gt;"nj"&lt;/font&gt;);&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//its 
  smart... it knows there's no such month as 21, so it must be 2&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;font color="#7F007F"&gt;&lt;i&gt;echo&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;add&lt;/font&gt;(&lt;font color="#007F00"&gt;"month"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;1&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//outputs: 
  319&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;=&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#7F007F"&gt;&lt;i&gt;new&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt; 
  Date_Time_Calc&lt;/font&gt;(&lt;font color="#007F00"&gt;"119"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#007F00"&gt;"nj"&lt;/font&gt;);&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//this 
  defaults to November 9th, not January 19th.&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;font color="#7F007F"&gt;&lt;i&gt;echo&lt;/i&gt;&lt;/font&gt;&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#00007F"&gt;&lt;i&gt;$obj&lt;/i&gt;&lt;/font&gt;-&amp;gt;&lt;font color="#000033"&gt;add&lt;/font&gt;(&lt;font color="#007F00"&gt;"month"&lt;/font&gt;,&lt;font color="#000033"&gt;&lt;/font&gt;&lt;font color="#CC9900"&gt;1&lt;/font&gt;);&lt;br /&gt;
  &lt;font color="#666666" face="Comic Sans MS"&gt;&lt;i&gt;//outputs: 
  129&lt;/i&gt;&lt;/font&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;font color="#0000FF"&gt;?&amp;gt;&lt;/font&gt;&lt;/font&gt;
&lt;br /&gt;
&lt;br /&gt;

I hope you find this class helpful. Click the download link below to download the source code.

&lt;br /&gt;&lt;br /&gt;
&lt;strong&gt;More examples can be found at: &lt;/strong&gt;&lt;a href="http://www.elacdude.com/code/date_time_calculator/example.html" target="_blank"&gt;http://www.elacdude.com/code/date_time_calculator/example.html&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="color:#000000;"&gt;To download this class, go to:&lt;/span&gt;&lt;/strong&gt;
&lt;a href="http://www.phpclasses.org/browse/package/4635.html" target="_blank"&gt;http://www.phpclasses.org/browse/package/4635.html&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;strong&gt;For a list of currently supported date/time modifiers, go to:&lt;/strong&gt;
&lt;a href="http://www.elacdude.com/code/date_time_calculator/date_time_formats.html" target="_blank"&gt;http://www.elacdude.com/code/date_time_calculator/date_time_formats.html&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;strong&gt;To test this class and see it in action, go to:&lt;/strong&gt;
&lt;a href="http://www.elacdude.com/code/date_time_calculator/index.php" target="_blank"&gt;http://www.elacdude.com/code/date_time_calculator/index.php&lt;/a&gt;

&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;


&lt;a href="http://www.phpclasses.org/browse/package/4635.html" target="_blank"&gt;&lt;span style="font-size:180%;"&gt;Download this class at phpclasses.org&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size:180%;"&gt; &lt;/span&gt;
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8828652504552320257-5756503559235868501?l=caleorosz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://caleorosz.blogspot.com/feeds/5756503559235868501/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8828652504552320257&amp;postID=5756503559235868501' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8828652504552320257/posts/default/5756503559235868501'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8828652504552320257/posts/default/5756503559235868501'/><link rel='alternate' type='text/html' href='http://caleorosz.blogspot.com/2008/11/my-php-date-and-time-calculator-class.html' title='My PHP Date and Time Calculator Class'/><author><name>elacdude</name><uri>http://www.blogger.com/profile/04031211595081805191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_0w-fuejUVus/SQtuNfK0E0I/AAAAAAAABU8/48VGaMSbIrI/S220/cale_sm.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8828652504552320257.post-4382165383660531050</id><published>2008-10-31T19:41:00.000-07:00</published><updated>2008-11-05T11:50:11.723-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='theories'/><category scheme='http://www.blogger.com/atom/ns#' term='efficiency'/><title type='text'>Always prepare for high amounts of traffic</title><content type='html'>Today at work I did some brainstorming about how I can make our website more efficient for high traffic. My company expects about 50,000 visitors by the end of the year so I wanted to figure out the BEST possible way to execute the database queries on the site.
&lt;br /&gt;&lt;br /&gt;
For each ad on our site there is a counter that counts how many page views the ad has. So every time an ad page is visited it requires a select statement and an update statement (to update the page view count).
&lt;br /&gt;&lt;br /&gt;
On a normal website, a solution like this may be fine:
&lt;br /&gt;&lt;br /&gt;
- select * from table where id='123'&lt;br /&gt;
- update table set views='4'&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;

But with a high traffic site, things should be done differently if you want it to run as fast as possible. See a MySQL &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;InnoDB&lt;/span&gt; table uses row level locking which means nobody can access that particular row while it is being updated.
&lt;br /&gt;&lt;br /&gt;
On a high traffic website, the above solution would do this:
&lt;br /&gt;&lt;br /&gt;
-User A requests ad page.&lt;br /&gt;
-User A's page loads and is currently updating row 5 of the ads table.&lt;br /&gt;
-Meanwhile user B requests that same ad page. But he/she must wait until User A is done updating row 5 of the ads table.&lt;br /&gt;
&lt;br /&gt;
Not good. On a very high traffic website there would be a lot of waiting. But there is a different way. Instead of using a column in the ads table to hold the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;pageview&lt;/span&gt; count, create a table that is only for holding &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;pageview&lt;/span&gt; counts. This way, while the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;pagecount&lt;/span&gt; table is being updated, it &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_4"&gt;doesn't&lt;/span&gt; get in the way of the select statements done on the ads table.
&lt;br /&gt;&lt;br /&gt;
The second solution would act like this on a high traffic web site:
&lt;br /&gt;&lt;br /&gt;
-User A requests ad page.&lt;br /&gt;
-User A's page loads.&lt;br /&gt;
-At the very end of the page, an update statement is executed on the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;pageview&lt;/span&gt; table.
-Meanwhile, User B requests that same ad page. The page loads &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_6"&gt;immediately&lt;/span&gt; &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_7"&gt;because&lt;/span&gt; that row in the ad table is not locked out due to the update in the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;pagecount&lt;/span&gt; table instead of the ads table.&lt;br /&gt;
&lt;br /&gt;
Much better. No wait time, no locked rows. The content is delivered as fast as possible to the user.
&lt;br /&gt;&lt;br /&gt;
You may think, well how do you update the page count without first executing a select statement to figure out what the CURRENT page count is? After all, how can we update the page count to plus 1 if we don't know what it is already?
&lt;br /&gt;&lt;br /&gt;
Well, the answer to that is the following:
&lt;br /&gt;&lt;br /&gt;
Update &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_9"&gt;pageviews&lt;/span&gt; set views=views+1 where id='5'
&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
So now we have a fast and efficient high traffic web site serving content &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_10"&gt;uninterrupted&lt;/span&gt; to users.
&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8828652504552320257-4382165383660531050?l=caleorosz.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://caleorosz.blogspot.com/feeds/4382165383660531050/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8828652504552320257&amp;postID=4382165383660531050' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8828652504552320257/posts/default/4382165383660531050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8828652504552320257/posts/default/4382165383660531050'/><link rel='alternate' type='text/html' href='http://caleorosz.blogspot.com/2008/10/always-prepare-for-future.html' title='Always prepare for high amounts of traffic'/><author><name>elacdude</name><uri>http://www.blogger.com/profile/04031211595081805191</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='http://3.bp.blogspot.com/_0w-fuejUVus/SQtuNfK0E0I/AAAAAAAABU8/48VGaMSbIrI/S220/cale_sm.gif'/></author><thr:total>0</thr:total></entry></feed>
