views:

20

answers:

1

I have numeric data with numbers representing the event that happened. Events can be public or private. I have 2 choices and I don't know which one to use (is faster).

  1. I can make 2 columns, 1 is the event column and the values are like 1...10. The other is the public/private smallint column that says if the event is public or private.

  2. I can make only one columns and number private events from 1...10 and public events from like 100...120. I have therefore "hid" the Event type into this column.

Now I want to filter with select of course... I would filter the first approach as SELECT * from event_table WHERE EventType=1

I would filter the second approach like: SELECT * from events_table WHERE EventID>100

Now what I really want to know, is the numeric = condition (contant) any faster than < or > (of course I will index this column!). With the second approach I would need one column less. I am not even sure if this is good or not...

Any advise would be appreceated.

Jerry

+3  A: 

I'm not sure if there is some micro performance difference between the two approaches (I doubt it), but I would definitely go for the first approach. Mixing different types of information in one column is not something that I would recommend.

Daniel Vassallo
Thanx. Problem is if I put data in another column I need to pass another info of the type or calculate it from the event ID. I am duplicating information then.
Jerry2
But you wanted to say that using > or < is also fast for integer indexed columns?
Jerry2