8
I need help to optimize this MySQL query for better and fast performance.
Here is the SQL FIDDLE with Query and table structure.
basically I have two tables
tbl_category
CREATE TABLE IF NOT EXISTS `tbl_category` (
`category_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`category_name` varchar(20) NOT NULL,
`parent_category_id` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`category_id`),
UNIQUE KEY `category_name` (`category_name`,`parent_category_id`),
KEY `category_parent_id` (`parent_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- data for table `tbl_auction`
--
+-------------+---------------+--------------------+-----------------+
| category_id | category_name | parent_category_id | category_status |
+-------------+---------------+--------------------+-----------------+
| 1 | Boats | NULL | a |
| 2 | Books | NULL | a |
| 3 | Building | NULL | a |
| 4 | Cars | NULL | a |
| 5 | Electrical | 3 | a |
| 6 | Hardware | 3 | a |
| 7 | Heating | 3 | a |
| 8 | Miscellaneous | 3 | a |
| 9 | Plumbing | 3 | a |
| 10 | Tools | 4 | a |
| 11 | Lights | 4 | a |
| 12 | Miscellaneous | 4 | a |
+-------------+---------------+--------------------+-----------------+
tbl_auction
CREATE TABLE IF NOT EXISTS `tbl_auction` (
`auction_id` int(10) unsigned NOT NUL