chapter31

development in a land far far away…

at the moment

History is not what happened. History is what was written down.

Archive for the 'Databases' Category

Yesterday I posted on a handy MySQL feature where you can combine an INSERT and UPDATE on a record in the one statement.
Someone asked about the performance of this so I ran a little test to get some basic numbers.
One thing to note is that even when MySQL is actually UPDATING your record (ON DUPLICATE […]

Read the rest of this entry »

INSERT or UPDATE in one statement with MySQL

Wednesday, April 23rd, 2008

A little while ago I mentioned combining multiple INSERT statements with MySQL, here is another helpful approach to a common problem.
In many systems you will give the user a chance to ADD and EDIT a record, a News post for example. As usual there are many ways to handle writing any changes to the database, […]

Read the rest of this entry »

As all developers know, one of the most common bottlenecks in a web application is the database. Database optimisation is therefore a huge part of building a streamlined application capable of handling more concurrent users.
Often you might have the need to perform multiple INSERT’s against a database from a single user form submission.
Let’s say you […]

Read the rest of this entry »

Random database results with ColdFusion

Friday, March 21st, 2008

Today I was looking at returning random records purely from MySQL but was limited with large tables in getting all random results (not just a random starting seed).
I tried a ColdFusion solution instead.
First get all the primary keys from the table in question and create an array of the values (this works for numeric […]

Read the rest of this entry »

Returning random results with MySQL

Friday, March 21st, 2008

Selecting random query results is something we often need to do, whether it be a single row or a small record set. You may want to display a random list of “tips” or “facts”, a random “user” or “related product” etc.
The simplest and most common solution you find uses the MySQL rand() function (which can […]

Read the rest of this entry »