O'Reilly logo

Web Performance Tuning, 2nd Edition by Patrick Killelea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performance Tips

A web site that exists for database access should be planned around the database. First, decide what sort of load the database will have to handle, and then choose web server software and hardware based on that load. The database will probably have to do much more work than the web server, so the database will be the bottleneck.

Prepared Statements and Bind Variables

You can store a preparsed statement in the database with variables in specific positions. These variables are called “bind variables.” The performance of prepared statements is much greater than statements that must be parsed and optimized before execution, but there is overhead in setting up the statement to begin with.

Prepared statements are best used when you will be making many nearly identical queries, differing only in the value of specific query values rather than differing in structure or tables. Note that the storage of a prepared statement is rather expensive, so that is the part you want to do only once, not in a loop.

Denormalize Tables

Some performance gains can be had simply by storing the most common data together in the same tables, avoiding expensive join operations. This also makes it easier to write queries, since a single table can then be used where otherwise you would have to do a join. On the other hand, denormalized tables increases the possibility of data inconsistencies, where data that is supposedly identical is different in different tables. Denormalized tables are also ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required