Hi,
First of all I must to mention that the database will receive 40000 inserts/day and probably 10000+ requests.
I have a table with many fields(20), most all of them are integer. Three of them are varchar(100).
My question is how to design the table/tables to obtain maximum performance on these varchar fields.
I need, grouping and counting for these fields.
For example I take only one field.
f1
value_f11
value_f12
value_f11
One query should give me
text cnt
value_f11 2
value_f12 1
I see 2 solutions:
1. To put proper index on each field and grouping on varchar
Pros: simplicity
Cons: - I know grouping on varchar(100) even with proper indexes it's not terrible.
- in the time the table will grow and each insert will be a performance hit because on indexes.
2. To make a child table for each varchar field with the following structure
id int, text varchar(100)
In the original table I must change the field type in integer and putting the id.
Pros: a faster grouping and counting(now we have a int field)
Cons: -more overhead on insert, i need to search the field value in child table, to get the id. If not found, insert and get id.
-the index on varchar is always needed, otherwise child, table scan for getting the id
So, anyone has a better solution, or has implemented something like this ?
Thanks
First of all I must to mention that the database will receive 40000 inserts/day and probably 10000+ requests.
I have a table with many fields(20), most all of them are integer. Three of them are varchar(100).
My question is how to design the table/tables to obtain maximum performance on these varchar fields.
I need, grouping and counting for these fields.
For example I take only one field.
f1
value_f11
value_f12
value_f11
One query should give me
text cnt
value_f11 2
value_f12 1
I see 2 solutions:
1. To put proper index on each field and grouping on varchar
Pros: simplicity
Cons: - I know grouping on varchar(100) even with proper indexes it's not terrible.
- in the time the table will grow and each insert will be a performance hit because on indexes.
2. To make a child table for each varchar field with the following structure
id int, text varchar(100)
In the original table I must change the field type in integer and putting the id.
Pros: a faster grouping and counting(now we have a int field)
Cons: -more overhead on insert, i need to search the field value in child table, to get the id. If not found, insert and get id.
-the index on varchar is always needed, otherwise child, table scan for getting the id
So, anyone has a better solution, or has implemented something like this ?
Thanks