Oct
31
2008
0

Low CPU Load Delays with SQL

Use WAITFOR to pause scripts while using minimal CPU overhead.

WAITFOR TIME '09:15'; --Wait until 9:15am
 
WAITFOR DELAY '00:00:05' --Wait for 5 seconds

It is NOT advisable to introduce delays into scripts while transactions are open. 

Reference: http://msdn.microsoft.com/en-us/library/ms187331.aspx

Written by John Burns in: SQL Tips, Tips |
Oct
28
2008
0

Covering Indexes in SQL 2005

For some strange reason, covering indexes are not used or understood as much as they should.

To quote Microsoft… “A Covering Index is a nonclustered index built upon all of the columns required to satisfy a SQL Server query, both in the selection criteria and in the WHERE clause”.

Lets look at it from a technical perspective.

We have a table:

CREATE TABLE dbo.testTable (
sysID		INT 		IDENTITY(1,1)	PRIMARY KEY,
firstName 	VARCHAR(64)	NOT NULL,
lastName 	VARCHAR(64)	NOT NULL,
employeeID 	SMALLINT	NOT NULL	UNIQUE NONCLUSTERED
)

As you can see above, for some other (we’ll assume good) reason we’ve put a primary key and hence a clustered index on the sysID. We’ve also put a unique nonclustered constraint on employeeID.

Consider the following query:

SELECT	firstName
FROM	testTable
WHERE	employeeID = 12345

When this query is executed, the unique nonclustered index is searched for the employeeID value of 12345. Once found, the nonclustered index will return a pointer to the actual row of the table. At this point, the row is looked up and the firstName is retrieved.

With a covering index, all of the required data is included in the index. In this simple case, we could just create an ascending index on employeeID and firstName to create a covering index, but lets assume that the total amount of data in the index is more that 900 bytes per record (the limit for a index entry) but we need more than this limit. In this case we can use the INCLUDE clause.

We can use the following sql (drop the table first if it exists):

CREATE TABLE dbo.testTable (
sysID		INT 		IDENTITY(1,1)	PRIMARY KEY,
firstName 	VARCHAR(64)	NOT NULL,
lastName 	VARCHAR(64)	NOT NULL,
employeeID 	SMALLINT	NOT NULL
);
GO
 
CREATE UNIQUE NONCLUSTERED INDEX
	IX_dbo_testTable_employeeID_INC_firstName
ON		dbo.testTable(employeeID ASC)
INCLUDE	(firstName);
GO

Now, when the select statement earlier in this post is executed, all the data required to complete the query is “covered” in the index.

A covering index saves a table join to get the results. You can easily expect a 200% performance increase on most queries.

Written by John Burns in: SQL Tips, Tips |
Oct
23
2008
0

Making the USB Remote

I’ve picked up my pieces from Maplin and started building my remote.

I’ve been playing around and found that with my cameras, they seem happy receiving 9 volts to trigger them. This makes the circuit very simple.

Disclaimer: USB is supposed to only work on 5 volts, YOU should use 5 volts. The camera ’should’ have built in regulation to reglate the power supply….I’m not sure but I used 9 volts and it works for me and I took the risk of breaking a camera to try it. In other words, “Do as I say, not as I do.”.

The circuit I was working from is this:

Which was stolen from http://stereo.jpn.org/eng/sdm/quick.htm which has detailed instructions for making the remote and installing the software onto the memory cards.

Basically, the camera can be triggered when 5 volts is supplied across the normal power supply lines.
I’m going to destroy the two cables that came with my cameras and the wires inside that were black and red (as per the USB specification).

Written by John Burns in: 3D Photography, Projects |
Oct
17
2008
0

A few things have arrived

I ordered a few items off the Bay of E and am getting excited about this project.

Here is the Flash Bracket I ordered:

It’s just a straight rail with TWO screws for mounting the cameras.

It’s already starting to look like I know what I’m doing:

(Yes, the cameras are running CHDK, but I’m still getting my head around it before I start posting about it)

I’ll try and get out and pick up the parts from Maplin to make my remote within the next week or so.

Written by John Burns in: 3D Photography, Projects |
Oct
16
2008
0

Giant Kiwi – No News is not Good News

I’m trying to find out the status of the markings on the land at the moment.

Hopefully they are still visible and my work wasn’t in vain.

For now though, you’ll have to make do with a view from google maps (links to google maps).

Written by John Burns in: Crop Kiwi |
Oct
12
2008
0

Dual camera 3D Photography

While back in New Zealand I picked up a couple of the “Canon Ixy Digital 10″ digital camera. Yes, it’s actually a Japanese model – I got then through Parallel Imported Ltd who as the name suggests, Parallel Import things.

I had a different project in mind for them at the time (which I still may do) but the main reason for this particular model was it was the most compact camera with a decent resolution (7.1 MegaPixels) which supports CHDK, the Canon Hacker Development Kit.

In a nutshell, CHDK is a modified firmware for the camera with the exception that it’s not actually firmware, it’s software and as such is booted from the memory card. In fact, take the memory card out or format it and the camera will use it’s standard built in firmware.

I wanted to play around with CHDK as it had a very basic scripting functionality which allows you to script (In a BASIC type language) the taking of photos, etc.

Anyway, one of the many branches of the CHDK code, StereoData Maker has been optimized for dual camera 3D photography. It supports a very basic USB interface for a remote switch and can (supposedly) synchronize two cameras pretty closely (something like 1/100 of a second).

I’ve decided to play around with it and will be documenting my results.

Here’s a picture of the two cameras just begging to be played with.

CHDK will allow you to write scripts for super high resolution time-lapse photography, or if you install the motion detection code, you can take photos of Lightning. I suggest checking if your camera is supported and if so, have a play with it. Unfortunately as the name suggests, it’s for Canon cameras Only.

Written by John Burns in: 3D Photography, Projects |