New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slow SQL #46

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

Comments

Projects
None yet
2 participants
@dead-horse
Member

dead-horse commented Dec 10, 2013

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';

有问题

@ghost ghost assigned dead-horse Dec 10, 2013

@fengmk2

This comment has been minimized.

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

This comment has been minimized.

Member

fengmk2 commented Dec 10, 2013

我会在tag增加一个module_id

fengmk2 added a commit that referenced this issue Dec 10, 2013

add module_id to tag table. #46
* make sure module_id exists
* make sure author is same

dead-horse added a commit that referenced this issue Dec 10, 2013

Merge pull request #47 from fengmk2/tag-module-id
add module_id to tag table. #46

fengmk2 added a commit that referenced this issue Dec 11, 2013

Merge pull request #50 from fengmk2/issue46-slow-sql
fix sql, change test to fit my local database, fixed #46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment