Closed Bug 468461 Opened 16 years ago Closed 14 years ago

Add an index to type column for tiki_comments

Categories

(support.mozilla.org :: Forum, task)

task
Not set
normal

Tracking

(Not tracked)

RESOLVED INCOMPLETE
Future

People

(Reporter: cww, Assigned: cww)

References

Details

Attachments

(1 file, 1 obsolete file)

Right now, searching for solved or "proposed solved" problems is killing my computer.  An index on the `type` column should help.

Although I could also be doing it wrong.
If this is any incentive, this will really really help performance of queries done with the forum filtered per bug 444331

And double incentive: here's the one-line SQL QUERY that will fix this bug

ALTER TABLE mozdump.tiki_comments ADD INDEX type(`type`);

(Of course, feel free to add more stuff if you think it's necessary)
CCing Laura.  This shouldn't require a push even so can it be done off schedule?
(In reply to comment #0)
> Right now, searching for solved or "proposed solved" problems is killing my
> computer.  An index on the `type` column should help.
> 
> Although I could also be doing it wrong.

What do your queries look like?
When doing a full count of how many threads are each type:

SELECT type, COUNT(1) FROM `tiki_comments` tc WHERE tc.object = 1 and tc.objectType = 'forum' and tc.parentId = 0 and FROM_UNIXTIME(commentDate) BETWEEN CAST('2008-12-02' AS Date) AND CAST('2008-12-09' AS Date) GROUP BY type;

Or even when I'm just pulling up a list of threads:

SELECT DISTINCT IF(parentId = 0, threadId, parentId) AS 'threads'
FROM tiki_comments WHERE type = 'r' AND `object`=1 AND `objectType` = 'forum' ORDER BY `commentDate` DESC LIMIT 20

(This pulls up the thread numbers of the last 20 commented-on threads which are marked request for more info... I do a secondary query on these to get the actual contents of the threads).

I've found it actually works faster to just build an index using ALTER TABLE ADD INDEX when I import the database since the time savings is made up for after just a couple queries.  This takes 15 minutes (during which computer is unusable) though and is clobbered every time I import again (at least once a week, sometimes twice).  It'd be nice just to have it there already.
Assignee: nobody → cwwmozilla
Target Milestone: --- → Future
Attached file query from comment 1 (obsolete) —
Made a patch so I can get review.
Attachment #384022 - Flags: review?(laura)
Cheng, perhaps we should add any not-currently-existing indexes from bug 498105 as well.
I would suggest not conflating the patches.  If you need those indexes make this bug dependent on that one.
Attachment #384022 - Attachment mime type: application/octet-stream → text/plain
Attachment #384022 - Flags: review?(laura) → review+
From bug 498105 comment 7: we don't actually need new indexes in addition the this one for bug 498105.  This patch should stand as is.
This patch is really low risk, can we just take it?
Target Milestone: Future → 1.3
(btw, this is just SQL, so should I just file a bug to have it run on staging and resolve this fixed?)
Depends on: 508431
Blocks: 498105
Attached file db-name-neutral query
took out DB name since that's not the same on all installs
Attachment #384022 - Attachment is obsolete: true
Attachment #393023 - Flags: review?(laura)
Attachment #393023 - Attachment mime type: application/octet-stream → text/plain
Attachment #393023 - Flags: review?(laura) → review+
Could we get some benchmarks as well?
Target Milestone: 1.3 → 1.5
I couldn't tell on sumotools so I guess we don't need to do this.  (It seems like a good idea though.
Target Milestone: 1.5 → Future
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: