Jump to content

How to run SQL-database faster, please give me examples.


Mudsaf

Recommended Posts

So far i know that columns with 1-5 character should be marked as "Char" instead of "Varchar" because of less memory usage. Does this run SQL-database faster if i just choose certain values like SELECT name, password FROM account instead of SELECT * FROM account? Does it actually mater do i choose char or varchar?

Link to comment
Share on other sites

Everything where you have a choice matters. If it didn't matter, you wouldn't have a choice. I wouldn't say that the difference between char and varchar is less memory usage. A char field is always a certain length. If you have a field of char 10, and put a value of length 5 in it, it will pad it with 5 extra spaces to make the length 10. varchar does not do that, the length of a varchar field is the maximum length that can go there. A char field is always a certain length even if it needs to be padded with spaces. It is more efficient to only select the columns you need instead of all columns. Exceptions are things like aggregate functions like COUNT, which may be optimized for COUNT(*), for example.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...