Your Ad Here
27th
April

Choosing Optimal MySQL Data Types

It is too often that developers use the wrong data types in their databases. As queries to databases take a major amount of time in any application, it is essential that the database and its tables are as optimised as possible to ensure the best efficiency, especially in high-demand applications. Read more »

14th
April

Making the Internet Faster: A Simple HTTP Improvement?

Let's face it: HTTP is old. The current version, 1.1, has been around since mid-1999 - and some systems still use 1.0! There is one thing that I don't get with HTTP, and other protocols: why are machine-languages always designed for human-interpretation? Read more »

24th
March

Saving Bytes: Efficient Data Storage (MySQL) - Part 1

When storing data in databases, it is important to ensure the data is stored using a minimal amount of space, while retaining its value and processing efficiency.

There are many common practices amongst MySQL developers who write applications which store data in a human-interpretable way; they often don't think about the computer's interpretation of the data, and often fail to realise that it can be more efficient and space-saving to store data in a certain form.

It is especially important to consider data storage techniques in high-demand applications, and where speed and storage-efficiency are key values. Web services require these key values: it is important that they can cope with extra demand, and can satisfy their user's desire for immediacy.

MySQL DataTypes
(Screenshot from phpMyAdmin)

In the first part of Saving Bytes: Efficient Data Storage, we will look at the storage of strings.
Read more »

16th
February

Tips for Faster JavaScript Scripts

So, after a reasonably successful "Tips for Faster PHP Scripts" series, I've thought about what else I could write about. As I've been using JavaScript quite a lot recently, I decided to write about ways to improve scripts so they run faster.

It is important than JavaScript scripts are fast, because you can not determine the execution speed on the wide range of clients' browsers.

You can not also determine how fast peoples' internet connections are, so it is important that the scripts get to the clients' browsers as fast as possible.

Some of these tips may not be entirely practical and may make the scripts harder to maintain, but I believe there should be compromise between making maintainable code and speed- and resource- efficient code.

1. Combining Scripts to One File

When Javascript files are requested, the server sends a few headers. Sometimes these headers can take more bytes than actual JavaScript itself.

For example, if 5 single JavaScript files are requested, they each will be received like this (with headers shown):

HTTP/1.1 200 OK
Date: Sat, 16 Feb 2008 18:55:10 GMT
Server: Apache/2.2.4 (Win32) mod_ssl/2.2.3 OpenSSL/0.9.8d PHP/5.2.1
Last-Modified: Sat, 16 Feb 2008 18:55:08 GMT
ETag: "6d37-86-fd04022"
Accept-Ranges: bytes
Content-Length: 134
Connection: close
Content-Type: application/x-javascript

function aFunctionName(arg1, arg2) {
if(arg1 == arg2)
return 0;
if(arg1 < arg2)
return -1;
if(arg1 > arg2)
return 2;
}

The total size of this transmission, including headers, is 424 bytes. The code itself is just 125 bytes. If similar code was loaded 5 times, the total size of the transmissions will be 2120 bytes. If, though, all the code was put into one file, the size of transmission would be 933 bytes, a saving of about 56%.
Read more »