I have to store user credits which can be in decimal format like (10.99, 0.99, etc.). For now i am taking the column field as varchar(100).
what if i use decimal instead of varchar. will it be improving the performance??
解决方案
The short answer is: No, it will hurt performance.
The longer answer: VARCHAR fields are variable length, meaning, that the formatting of the database blocks cannot pre-account for the size of the data filling in there. Sure, there's a maximum length of the field, but other than that, you're off worse.
On the other hand, reading a VARCHAR and then interpreting it to fit into a floating point type will cost you. And it introduces new problem possibilities. Try to get all decimals that account for "11.99". Hope you bring the right number of decimal places, because in VARCHAR "11.99" != "11.990".
And then there's indexing. Usually, nobody indexed a decimal field, but on the off chance that you do, an index on a VARCHAR field will require more space.
All in all, it's not a good idea to save something in an unspecific field type. In the DB structure, it's usually considered best practice to be as specific as possible.