Closed
Bug 481257
Opened 15 years ago
Closed 15 years ago
Insertion triggers are unnecessarily slow
Categories
(Toolkit :: Places, defect, P2)
Toolkit
Places
Tracking
()
RESOLVED
FIXED
People
(Reporter: sdwilsh, Assigned: bzbarsky)
References
Details
(Keywords: fixed1.9.1, perf, Whiteboard: [good first bug])
Attachments
(2 files)
2.06 KB,
patch
|
sdwilsh
:
review-
|
Details | Diff | Splinter Review |
2.06 KB,
patch
|
sdwilsh
:
review+
|
Details | Diff | Splinter Review |
Spun out of bug 481113. In our insertion triggers, we have a bit of SQL that looks like this: MAX((SELECT IFNULL(MAX(id), 0) FROM moz_places_temp), (SELECT IFNULL(MAX(id), 0) FROM moz_places)) + 1 We use this to determine the new insertion id. The trigger for moz_historyvisits is very similar. The bad news is that how this is written, it requires a full table scan of each table. According to drh, this is the likely culprit since we are spending a bunch of time in sqlite3VdbeExec. We can let the optimizer use the index instead of a table scan if we change those bits to the following: MAX(IFNULL((SELECT MAX(id) FROM moz_places_temp), 0), (IFNULL(SELECT MAX(id) FROM moz_places), 0)) + 1 Note the change of location for IFNULL.
Reporter | ||
Updated•15 years ago
|
Whiteboard: [good first bug]
Updated•15 years ago
|
Assignee: nobody → ddahl
Assignee | ||
Comment 1•15 years ago
|
||
If there's a quick-n-dirty way that I can convert an existing profile to one that uses the new trigger, I'd love to give this a test! I assume there's more to it than just replacing that string in our code, since we'd need to convert existing tables?
Reporter | ||
Comment 2•15 years ago
|
||
because it uses temp tables, it's created at every startup (sucky, yes). It is just a simple string replace.
Comment 3•15 years ago
|
||
I had an assertion thrown, but all tests passed. Please apply this and run the test suite - let me know if there are any failures
Attachment #365294 -
Flags: review?(sdwilsh)
Reporter | ||
Updated•15 years ago
|
Attachment #365294 -
Flags: review?(sdwilsh) → review+
Reporter | ||
Comment 4•15 years ago
|
||
Comment on attachment 365294 [details] [diff] [review] WIP patch 0 r=sdwilsh, thanks!
Assignee | ||
Comment 5•15 years ago
|
||
If all tests passed, the test suite is broken. Both the strings in comment 0 and the ones in that patch are misparenthesized, no? From the patch: + "VALUES MAX(IFNULL((SELECT MAX(id) FROM moz_places_temp), 0),"\ + "(IFNULL(SELECT MAX(id) FROM moz_places), 0)) + 1, " \ This is missing a parenthesis before the first "MAX". It's got an extra parenthesis before the second IFNULL. I would fully expect this query to fail to execute (and in fact when I initially tried the suggested fix that's exactly what I saw happening here, until I fixed the parens).
Assignee | ||
Comment 6•15 years ago
|
||
I haven't run the relevant test suite on this, but I _did_ run reftest as described in bug 481113. Instead of taking 17 minutes, it took about 8, which is pretty close to what it takes in a vanilla profile. So as far as I can tell this patch fixes that bug.
Reporter | ||
Comment 7•15 years ago
|
||
(In reply to comment #5) Yes, it was subtly incorrect, but really hard to see until I did some indentation: MAX( IFNULL( (SELECT MAX(id) FROM moz_places_temp), 0), IFNULL((SELECT MAX(id) FROM moz_places), 0) ) + 1 Which is what your patch does. Parens are hard to read sometimes :)
Reporter | ||
Updated•15 years ago
|
Attachment #365294 -
Flags: review+ → review-
Reporter | ||
Comment 8•15 years ago
|
||
Comment on attachment 365297 [details] [diff] [review] What I was just testing r=sdwilsh on this, with the correct parens.
Attachment #365297 -
Flags: review+
Updated•15 years ago
|
Flags: blocking1.9.1?
Reporter | ||
Comment 9•15 years ago
|
||
Yes, this should absolutely block as it's a major slowdown.
Assignee | ||
Comment 10•15 years ago
|
||
We should add some tests that would catch the incorrect parens too.
Comment 11•15 years ago
|
||
(In reply to comment #10) > We should add some tests that would catch the incorrect parens too. sync tests should notice a problem in syncing queries
Reporter | ||
Comment 12•15 years ago
|
||
yeah, don't understand how tests were passing to be honest.
Comment 13•15 years ago
|
||
Good to see our new friend "bz" fixing a "good first bug". ;p
Assignee | ||
Comment 14•15 years ago
|
||
It's shawn's fix, I tell you! Oh, and and as far as parens being hard to read, just put (show-paren-mode t) in your .emacs. If you're not using emacs, maybe it's time to start! ;)
Reporter | ||
Comment 15•15 years ago
|
||
With the original attachment on this bug, every test fails for me, with this showing up in the log: WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005: file /Code/moz/central/mozilla/toolkit/components/places/src/nsNavHistory.cpp, line 1046 WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005: file /Code/moz/central/mozilla/toolkit/components/places/src/nsNavHistory.cpp, line 895 WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005: file /Code/moz/central/mozilla/toolkit/components/places/src/nsNavHistory.cpp, line 1046 WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005: file /Code/moz/central/mozilla/toolkit/components/places/src/nsNavHistory.cpp, line 895 WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80004005: file /Code/moz/central/mozilla/toolkit/components/places/src/nsNavHistory.cpp, line 448 So, I'm not sure how they passed before.
Reporter | ||
Comment 16•15 years ago
|
||
Boris - can you check this in, or should someone on the places team do this for you?
Assignee: ddahl → bzbarsky
Assignee | ||
Comment 17•15 years ago
|
||
OK, those warnings were exactly what I saw when I screwed up the parens. I can push this.
Assignee | ||
Comment 18•15 years ago
|
||
Pushed http://hg.mozilla.org/mozilla-central/rev/92ea141a0969
Status: NEW → RESOLVED
Closed: 15 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Updated•15 years ago
|
Flags: blocking1.9.1? → blocking1.9.1+
Keywords: perf
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Assignee | ||
Comment 19•15 years ago
|
||
Pushed http://hg.mozilla.org/releases/mozilla-1.9.1/rev/875b7fd92b0b
Keywords: fixed1.9.1
Comment 20•15 years ago
|
||
I think this was pushed to the wrong branch, i.e. the 3.1 beta3 branch...
Comment 21•15 years ago
|
||
oh right. this should be on "default" branch, not b3 :\
Comment 23•15 years ago
|
||
Please revert revision 875b7fd92b0b on mozilla-1.9.1.
Assignee | ||
Comment 24•15 years ago
|
||
Oh, crap. Silly tip vs not tip stuff. Fixing.
Assignee | ||
Comment 25•15 years ago
|
||
Pushed http://hg.mozilla.org/releases/mozilla-1.9.1/rev/fd8ca820c460 to back out on the relbranch.
Assignee | ||
Comment 26•15 years ago
|
||
Gah. Also pushed http://hg.mozilla.org/releases/mozilla-1.9.1/rev/790666cd7d3d to back out the part that accidentally landed with the backout. I have now verified that current GECKO191b3_20090304_RELBRANCH is identical to the parent of rev 875b7fd92b0b.
Assignee | ||
Comment 27•15 years ago
|
||
Pushed http://hg.mozilla.org/releases/mozilla-1.9.1/rev/c17faff8dd0c on the right branch.
Assignee | ||
Updated•15 years ago
|
Keywords: fixed1.9.1
You need to log in
before you can comment on or make changes to this bug.
Description
•