slow SQL #46

Closed
dead-horse opened this Issue Dec 10, 2013 · 2 comments

Projects

None yet

2 participants

@dead-horse
Member
var LIST_BY_AUTHOR_SQL = 'SELECT name, package FROM module WHERE id IN \
                          (SELECT max(id) FROM module WHERE author=?\
                          GROUP BY name )\
                          ORDER BY name';

var LIST_SINCE_SQL = 'SELECT name, package FROM module WHERE id IN \
                     (SELECT max(id) FROM module WHERE gmt_modified > ?\
                      GROUP BY name )\
                     ORDER BY name';

有问题

@dead-horse dead-horse was assigned Dec 10, 2013
@fengmk2
Member
fengmk2 commented Dec 10, 2013
CREATE TABLE `tag` (
 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'primary key',
 `gmt_create` datetime NOT NULL COMMENT 'create time',
 `gmt_modified` datetime NOT NULL COMMENT 'modified time',
 `name` varchar(100) NOT NULL COMMENT 'module name',
 `tag` varchar(30) NOT NULL COMMENT 'tag name',
 `version` varchar(30) NOT NULL COMMENT 'module version',
 `module_id` bigint(20) unsigned NOT NULL COMMENT 'module id',
 PRIMARY KEY (`id`),
 UNIQUE KEY `name` (`name`, `tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='module tag';
-- ALTER TABLE  `tag` ADD  `module_id` BIGINT( 20 ) UNSIGNED NOT NULL ;
@fengmk2
Member
fengmk2 commented Dec 10, 2013

我会在tag增加一个module_id

@fengmk2 fengmk2 added a commit that referenced this issue Dec 10, 2013
@fengmk2 fengmk2 add module_id to tag table. #46
* make sure module_id exists
* make sure author is same
57f05d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment