Tag Archives: Performance

Localhost Slow on Windows 7

I had some trouble figuring out why http://localhost, was responding slow compared to 127.0.0.1 when accessing my local apache http server. It turned out that by default the hosts file contains the following line:

# 127.0.0.1 localhost

By uncommenting this line, as follows (remove the hash):

127.0.0.1 localhost

A DNS look-up will then never be performed before it is determined that localhost is actually 127.0.0.1.

Posted in Windows | Tagged , , , , | 1 Comment

Select count from multiple tables

Sometimes a parent table have more than one table with multiple references to a field in the parent table. Then the question is how to count references from more than one table in a single query. I have found 5 different ways to achieve this result, and therefore I have run a few tests, to see which was better.

To test this I made this small PHP script, that creates a parent table and child table. Then a loop populates the tables with 1,000 parent rows, approximately 15 children of type 1 and approximately 75 children of type 2. This is done before each query, to make sure that all queries have the same conditions.

Continue reading
Posted in MySQL, PHP | Tagged , , , , , | 2 Comments