char vs varchar for performance in stock database

后端 未结 5 2043
难免孤独
难免孤独 2020-12-31 11:06

I\'m using mySQL to set up a database of stock options. There are about 330,000 rows (each row is 1 option). I\'m new to SQL so I\'m trying to decide on the field types for

5条回答
  •  有刺的猬
    2020-12-31 11:16

    I would definitely not recreate the database each time. Instead I would do the following:

    • read in the update/snapshot file and create some object based on each row.
    • for each row get the symbol/option name (unique) and set that in the database

    If it were me I would also have an in memory cache of all the symbols and the current price data.

    Price data is never an int - you can use characters.

    The company name is probably not unique as there are many options for a particular company. That should be an index and you can save space just using the id of a company.

    As someone else also pointed out - your web clients do not need to have to hit the actual database and do a query - you can probably just hit your cache. (though that really depends on what tables and data you expose to your clients and what data they want)

    Having query access for other users is also a reason NOT to keep removing and creating a database.

提交回复
热议问题