Hi,
Afan Pasalic wrote:
Baron Schwartz wrote:
Hi Afan,
Afan Pasalic wrote:
hi,
if I have column order_id(int(4)) null do I have to index it too. I'm
going to use it ONLY for sorting records.
It depends a lot on how much data is in the table, etc etc. An index
will make sorting more efficient in the general case when you have a
decent amount of data. But it's hard to be specific with so little
information.
Baron
I have table products (product_id is PK). I have table categories
(cat_id is PK). since the product can be in more than one category, I
have prod_cat table:
create prod_cat(
cat_id int(8) unsigned not null,
prod_id int(8) unsigned not null,
order_id int(4) unsigned null,
PRIMARY KEY (cat_id, prod_id)
) engine=Innodb;
Okay, so your order_id is really sort order, not "id of the customer's request to buy
something." (As an aside, perhaps "sort_order" would confuse you less in the future
when you don't remember the column's purpose anymore).
It probably makes sense to index the column if you want to use it for sorting. You
could also just order by the primary key. But I understand there are times when you
want to have a different ordering.
Baron
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]