Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • What about storing the 8 digit code/number as a string and then using a functional index on the different characters? Or VIRTUAL fields derived from your 8 digit code. If these "numbers" are never added, divided or multiplied, then they should be stored as codes and not numbers - a bit like phones! BTW, I would recommend PostgreSQL over any MySQL deriveative - vastly superiour in virtually every way! Commented Apr 29, 2019 at 23:43
  • Thank you for your comment. Yes these numbers are never added, multiplied etc. they can be called codes. "stored as codes" you mean string data type, right? Is it rational to use VIRTUAL fields if I need the data on the "constant basis". I mean would it be rational to make SQL split the code to digits every single time I select thousands of codes versus storing them as digits in separate columns? Sorry, quite new to this. Commented Apr 30, 2019 at 0:51
  • 2
    Set them to CALCULATED - the calculation will be done on every query for any character [0 - 7] you choose. You have a really small amount of records so that won't be a problem. I have to go to bed now (it's 0200 in the morning), but I can write this up as an answer with a worked example or two tomorrow if you think that I've pretty much answered your question? Commented Apr 30, 2019 at 0:54
  • What is the preference? increase performance? decrease storage space? something else? Commented Apr 30, 2019 at 5:25
  • Just do option 1. 6000 rows + 2000 a year is nothing, you can do it all in memory in no time at all. Commented Apr 30, 2019 at 7:31