Tag Archives: Optimization

CakePHP 1.2 VS 1.3 VS 2.0 Page Request Times

When I first started using CakePHP a few years ago, we had a lot of complaints about speed.  If you do some Google searches comparing CakePHP to other frameworks, it seems to be near the bottom of the pack.  I previously wrote a few articles on optimizing CakePHP here:

Implementing the following tips certainly helped; however, if there are issues with the core framework response time, no amount of optimization will truley help.  So after reading up on CakePHP 2.0 and it’s recent speed improvements, I wanted to do some straight CakePHP comparisons.  Below are 10 load times for CakePHP 1.2, 1.3, and the new 2.0.  These load times are of a brand new install simply loading the default home view, no database connection or any model loading. Read more »

Share

Speeding up client/server response times

In the past 6 months I’ve switched jobs from being a web developer to being a server side game developer.  So far it’s been an excellent career shift.  I get to focus on my true passions, intelligent back-end code and no longer having to waste my time with frustrating design challenges (there is a separate team that does that).

Having said that, when developing large Facebook virtual worlds, there are a lot of client/server communication.  For example, each time someone buys something, each time you buy something, etc…  Currently, a lot of games wait for the server to respond, but why should we?  There are a lot of server calls that are done for informational purposes; just to keep the database up-to-date.  So I ask you, why should the end user wait for the server to catch up?  Let’s examine a simple approach to alleviate the need for the client to wait. Read more »

Share

Optimizing CakePHP Websites

CakePHP offers a lot of functionality to us as developers. The ability to develop websites rapidly provides a trade-off in how quickly the website will load. As we expand our skills, we will learn the techniques that will slow down/speed up performance.

Objectives

  • Apply techniques to speed up CakePHP’s load time
  • Optimize our queries
  • Cache query results

Read more »

Share

CakePHP Containable Statement Pitfalls

On some of our more recent projects, we have been using the Containable behavior that CakePHP provides.  It works quite nicely, a lot easier than the previous format of having to bind and unbind models on the fly.

The pitfalls began to appear when some of our clients were reporting that some pages are extremely slow.  After a bit of research, it was quite apparent that the root of the cause was attributed to us using the containable feature. Read more »

Share

Dynamic COUNT() Versus Static COUNT()

I’ll continue today with another good database programming article.  If you missed yesterdays, you may view it here.

Today’s article will discuss when to use a static COUNT() versus a dynamic COUNT().  On a regular basis we are tasked with creating a message center or a photo album and we need to display a count of new messages or pictures in the album.

The obvious solution is to do a simple query: SELECT COUNT(*) FROM pictures WHERE album_id = 1 and display the result beside our album name.  Now, let’s assume that we allow multiple albums our actual query would be closer to this: SELECT albums.*, COUNT(pictures.*) as picture_count FROM albums INNER JOIN pictures ON albums.id = pictures.album_id WHERE albums.id = 1.  This will of course work, but let me show you a better, more practical approach that will improve performance significantly on large databases. Read more »

Share

Why You Should Avoid ORDER BY RAND() OR NEWID()

Quite often we get a complaint from a client that their homepage is too slow.  The first thing we do is load the homepage up and see for ourselves.  Yep, it looks slow, so the next step is too see what is being done.  Quite often you’ll see some random data being displayed on the homepage.  Whether it’s random news articles, photos, videos, etc…If this is not the case, you may find my article on improving slow loading web pages more useful.

If the homepage is slow because of random data, you can lay a bet with high certainty that those 10 random articles are being pulled with an ORDER BY RAND() OR NEWID() slowing the site to a crawl.  In case you are curious the difference, RAND() is the MySQL way and NEWID() is the SQL Server way.  In this article, I’ll show you why you should avoid these functions and several different solutions to help you overcome this issue. Read more »

Share

SQL Tips – Why LEFT JOINS are bad

When you do SQL queries do you find yourself always, or almost always, using left joins?  If you’ve answered yes to this question, I would suggest to continue to read and understand some downfalls that you might be getting yourself into.

Let’s start by looking at a standard query that has a left join:

SELECT * FROM users u LEFT JOIN countries c ON c.id = u.country_id WHERE u.id = 5

The following query will return all fields from the users table and all fields from the countries table.  Now you’re thinking, “Yeah, looks good, so what’s wrong with this?”.  Well, I’m glad you asked. Read more »

Share

How to get indexed by Google in ONE hour

If you’re not familiar with how some people accomplish getting their web sites submitted to Google quickly, you are going to absolutely love this article.

I’ve bet you’ve heard from many people that it can take days, weeks, even months to get indexed by Google.  If you have heard that, you’re now thinking, “OK Jamie, you must have had a really stressful day at work today and you’re now hallucinating that this is possible!”.

If I read this blog title a while ago, I’m sure I would be thinking the same thing as you!  Ok, let’s move on to how to get indexed by Google within one hour. Read more »

Share

Buy one of my books