views:

49

answers:

2

I'm doing some queries that require a lot of joined rows have some of their fields added and multiplied together.

I know it is sort of vague, but my question is which numeric data type is fastest for these types of operations?

Will FLOAT be faster than DOUBLE since DOUBLE is 8 bytes, and FLOAT is 4?

Will INT be faster than FLOAT (even if they are both 4 bytes)?

Will DECIMAL be faster than FLOAT?

Here's some more information: The problem I'm solving allows me the option to store "float" numbers as BIGINTEGER's... I can just multiply the number by 100000 before inserting them. I'd be willing to do this if BIGINT's math was faster than FLOAT's.

Thanks.

A: 

In general, integer operations are quicker (and more accurate). Since I don't actually work in MySQL I can't say for certain--but I'd certainly bet in favor of Integers.

Jan Gorzny
+2  A: 

The byte size impacts data retrieval, not calculation based on it. Indexes can improve this if necessary, but will slow down UPDATE/INSERT/DELETE statements.

I suggest choosing the data type that reflects the operations you're going to be using. If you don't need the precision at all, there's no reason to consider using DECIMAL or FLOAT.

OMG Ponies