MySQL: why is a index column marked as "BTREE?" -
MySQL: why is a index column marked as "BTREE?" -
lets see 2 tables:
create table `orders_products` ( `order_id` int(10) unsigned not null, `product_id` int(10) unsigned not null, `quantity` tinyint(3) unsigned not null, `user_id` int(10) unsigned not null, primary key (`order_id`,`product_id`,`user_id`) using btree, key `fk_orders_products_3` (`user_id`), key `fk_orders_products_2` (`product_id`) **using btree**, constraint `fk_orders_products_1` foreign key (`order_id`) references `orders` (`id`) on delete cascade, constraint `fk_orders_products_2` foreign key (`product_id`) references `products` (`id`) on delete cascade, constraint `fk_orders_products_3` foreign key (`user_id`) references `users` (`id`) on delete cascade ) engine=innodb default charset=utf8;
another:
create table `products_pictures_comments` ( `picture_id` int(10) unsigned not null, `user_id` int(10) unsigned not null, `comment` text not null, `dateat` datetime not null, primary key (`picture_id`,`user_id`,`dateat`), key `fk_products_pictures_comments_2` (`user_id`), constraint `fk_products_pictures_comments_1` foreign key (`picture_id`) references `products_pictures` (`id`) on delete cascade on update cascade, constraint `fk_products_pictures_comments_2` foreign key (`user_id`) references `users` (`id`) on delete cascade on update cascade ) engine=innodb default charset=utf8;
as can see, using btree appears unknown reason. checked tables show index from
command, , of them said btree index_type. appears in fk_orders_products_2 foreign key. why?
edit: these table definitions generated show create table!
because btree (assuming means balanced rather binary) efficient info construction maintaining indexes.
it has reasonable insertion , deletion characteristics , very search characteristics.
if question more along lines of why isn't used everywhere, that's because uses other methods.
mysql
Comments
Post a Comment