[Slashdotjp-dev 1533] [1064] Fix slow query on getStoryByTime()

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 3月 11日 (水) 17:45:43 JST


Revision: 1064
          http://svn.sourceforge.jp/view?root=slashdotjp&view=rev&rev=1064
Author:   tach
Date:     2009-03-11 17:45:43 +0900 (Wed, 11 Mar 2009)

Log Message:
-----------
Fix slow query on getStoryByTime()

Modified Paths:
--------------
    slashjp/trunk/Slash/DB/MySQL/MySQL.pm
    slashjp/trunk/debian/changelog


-------------- next part --------------
Modified: slashjp/trunk/Slash/DB/MySQL/MySQL.pm
===================================================================
--- slashjp/trunk/Slash/DB/MySQL/MySQL.pm	2009-03-10 13:56:49 UTC (rev 1063)
+++ slashjp/trunk/Slash/DB/MySQL/MySQL.pm	2009-03-11 08:45:43 UTC (rev 1064)
@@ -5907,6 +5907,7 @@
 	my $limit   = $options->{limit}   || 1;
 	my $topic   = $options->{topic}   || '';
 	my $section = $options->{section} || '';
+	my $tables = 'stories JOIN story_text USING (stoid)';
 	my $where;
 	my $name  = 'story_by_time';
 	_genericCacheRefresh($self, $name, $constants->{story_expire} || 600);
@@ -5929,6 +5930,7 @@
 
 	my $mp_tid = $constants->{mainpage_nexus_tid} || 1;
 	if (!$section && !$topic && $user->{sectioncollapse}) {
+		$tables .= ' JOIN story_topics_rendered USING (stoid)';
 		my $nexuses = $self->getNexusChildrenTids($mp_tid);
 		my $nexus_clause = join ',', @$nexuses, $mp_tid;
 		$where .= " AND story_topics_rendered.tid IN ($nexus_clause)";
@@ -5943,7 +5945,11 @@
 		my $nexus_clause .= join ',', @$nexuses;
 		$where .= " AND (story_topics_rendered.stoid NOT IN (SELECT stoid FROM story_topics_rendered WHERE tid IN ($nexus_clause)) OR story_topics_rendered.tid = $mp_tid)"
 			if ($nexus_clause);
+		if ($user->{story_never_nexus} || $nexus_clause) {
+			$tables .= ' JOIN story_topics_rendered USING (stoid)';
+		}
 	} else {
+		$tables .= ' JOIN story_topics_rendered USING (stoid)';
 		$where .= " AND story_topics_rendered.tid = $mp_tid";
 		$key .= '|=';
 	}
@@ -5979,10 +5985,8 @@
 
 	my $returnable = $self->sqlSelectHashref(
 		'stories.stoid, sid, title, stories.tid',
-		'stories, story_text, story_topics_rendered',
-		"stories.stoid = story_text.stoid
-		 AND stories.stoid = story_topics_rendered.stoid
-		 AND '$time' > DATE_SUB($now, INTERVAL $bytime_delay DAY)
+		$tables,
+		"'$time' > DATE_SUB($now, INTERVAL $bytime_delay DAY)
 		 AND time $sign '$time'
 		 AND time <= $now
 		 AND in_trash = 'no'

Modified: slashjp/trunk/debian/changelog
===================================================================
--- slashjp/trunk/debian/changelog	2009-03-10 13:56:49 UTC (rev 1063)
+++ slashjp/trunk/debian/changelog	2009-03-11 08:45:43 UTC (rev 1064)
@@ -1,8 +1,8 @@
 slash (2.5.0.233-7) unstable; urgency=low
 
-  * NOT RELEASED YET
+  * Fix slow query on getStoryByTime()
 
- -- Taku YASUI <tach****@osdn*****>  Tue, 10 Mar 2009 10:25:23 +0000
+ -- Taku YASUI <tach****@osdn*****>  Wed, 11 Mar 2009 08:45:22 +0000
 
 slash (2.5.0.233-6) unstable; urgency=low
 



Slashdotjp-dev メーリングリストの案内
Back to archive index