Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Design database for optimum varchar grouping

Status
Not open for further replies.

xcata

Programmer
Jun 27, 2001
39
FR
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top