I am concerned with the performance of a database table i have to store data related
with a customer survey application.
I have a database table storing customer responses from a survey. Since the survey questions change according to customer i though instead of defining
the table schema using each questionid as column to define it as as follows
customerdata(customerid varchar,
partkey varchar,
questionkey varchar,
value, varchar,
version, int,
lastupdate, timestamp)
Where:
partkey: is the shortcode of the part (part1,part2…)
questionkey: is the shortcode of the question
e.g age, gender etc
since some customers fill the survey twice, thrice etc i have added the version column.
With this design customerid,partkey,questionkey and version are primary keys.
i am concerned about the performance with such design. Should i define the other primary keys as indexes ? Would that help ? So far for 30 customers i have 7000 records. I expect to have maximum 300-500. What do you think ?
Sounds like a pretty small database. I doubt you’ll have performance issues but if you detect any when querying on
partkey,questionkey, orversionlater on you can always add one or more indexes to solve the problem at that time. There’s no need to solve a performance problem you don’t have and probably never will have.Performance issues will arise only if you have to perform time-sensitive queries that don’t use the
customeridfield as the primary filter. I suspect you’ll have some queries like that (when you want to aggregate data across customers) but I doubt they’ll be time-sensitive enough to be impacted by the one second or less response time I would expect to see from such a small collection of data. If they are, add the index(es) then.Also, note that a table only has a single PRIMARY KEY. That key can use more than one column, so you can say that columns
customerid,partkey,questionkey, andversionare part of the PRIMARY KEY, but you can’t say their all “primary keys”.