Closed Bug 386711 Opened 17 years ago Closed 17 years ago

Use single queries in nsNavHistoryExpire methods

Categories

(Firefox :: Bookmarks & History, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
Firefox 3 alpha8

People

(Reporter: mak, Assigned: mak)

References

Details

Attachments

(2 files, 3 obsolete files)

Actually the following functions use a for cycle, and make a select and a delete on each iteration (2 sql queries per iteration).

That could be avoided creating a string with the list of IDs to delete and using a subquery. So instead of a for cycle made of queries we end up with a for cycle appending to a string and a single final query.

functions are:
nsNavHistoryExpire::EraseVisits
nsNavHistoryExpire::EraseHistory
nsNavHistoryExpire::EraseFavicons
Also EraseAnnotations (not yet implemented) could use the same method

I attach a patch to show the alternative method purposed, it should have less sqlite overhead cause it makes a single call insted of a call in every iteration.

These are my first patches and i'm learning, so please doublecheck.
I also need someone to checkin (if approved).
Assignee: nobody → mak77
Status: NEW → ASSIGNED
Attachment #270712 - Flags: review?(sspitzer)
Summary: Use single queries on nsNavHistoryExpire → Use single queries in nsNavHistoryExpire methods
Assignee: mak77 → nobody
Status: ASSIGNED → NEW
Component: History → Places
QA Contact: history → places
Sorry for the delay here, Marco.

Any reason why you re-assigned to nobody?
the re-assign has been made from Gavin sharp, i think he has his reasons (but don't know them)
Sorry, "re-assign to defaults" is selected automatically when you change components, and I forgot to unselect it.
Assignee: nobody → mak77
Status: NEW → ASSIGNED
Comment on attachment 270712 [details] [diff] [review]
Alternative method to do expire queries

there is possible problem here.
doing:
IN (1,2,3)
is different from doing:
IN ("1,2,3")

need to check how mozStorage handle deleteStatement->BindUTF8StringParameter
the string should be simply added to the string and not parsed anyway
Attachment #270712 - Flags: review?(sspitzer)
Attachment #270712 - Attachment is obsolete: true
i've rewritten the patch following naming and formatting conventions from the Dietrich's Annotation Expiry patch of Bug 319455.
it is now using ExecuteSimpleSQL instead of a useless statement, because it doesn't need anymore bindings.

This does not compile against current Trunk because it uses the nsNavHistoryRecord pageID -> placeID fix of Bug 319455, so this should land immediately after, or i can create a patch with pageID but then Dietrich should correct functions to use placeID when he lands his patch. 

Or maybe the best could be merge this patch into his work.
thanks marco! let's keep this patch separate just to keep the patch in 319455 to a manageable size.
Depends on: 319455
Target Milestone: --- → Firefox 3 M7
Attached patch updated patchSplinter Review
patch updated after landing of Dietrich's annotations patch

i'd like if Dietrich could check this before asking review to Seth
Attachment #271507 - Attachment is obsolete: true
Target Milestone: Firefox 3 M7 → Firefox 3 M8
Comment on attachment 274460 [details] [diff] [review]
updated patch

this looks good, thanks.
Attachment #274460 - Flags: review+
Checking in toolkit/components/places/src/nsNavHistoryExpire.cpp;
/cvsroot/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp,v  <--  nsNavHistoryExpire.cpp
new revision: 1.12; previous revision: 1.11
done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
It is hard to check without more thorough investigation but, if EraseHistory or EraseFavicons can ever end up with no deletions to check, this could add a query execution compared with the previous code - ... WHERE id IN () ... - in which case

if (deletedPlaceIds.IsEmpty())
    return NS_OK;

may be a sensible early return.
Attached patch followup, early returns (obsolete) — Splinter Review
followup patch, early returns as per previous comment (good catch)
Attachment #277695 - Flags: review?(dietrich)
fixes some space too
Attachment #277695 - Attachment is obsolete: true
Attachment #277697 - Flags: review?(dietrich)
Attachment #277695 - Flags: review?(dietrich)
Comment on attachment 277697 [details] [diff] [review]
followup, early returns, fixes some space



>     // Do not add comma separator for the first entry
>-    if(! deletedFaviconIds.IsEmpty() )
>+    if (! deletedFaviconIds.IsEmpty() )
>       deletedFaviconIds.AppendLiteral(", ");
>     deletedFaviconIds.AppendInt(aRecords[i].faviconID);
>   }
> 

no need for the extra space at the close parens either actually, i'll remove them before checkin. r=me otherwise.
Attachment #277697 - Flags: review?(dietrich) → review+
Checking in toolkit/components/places/src/nsNavHistoryExpire.cpp;
/cvsroot/mozilla/toolkit/components/places/src/nsNavHistoryExpire.cpp,v  <--  nsNavHistoryExpire.cpp
new revision: 1.13; previous revision: 1.12
done
(In reply to comment #14)
> (From update of attachment 277697 [details] [diff] [review])
> >     // Do not add comma separator for the first entry
> >-    if(! deletedFaviconIds.IsEmpty() )
> >+    if (! deletedFaviconIds.IsEmpty() )
> >       deletedFaviconIds.AppendLiteral(", ");
> >     deletedFaviconIds.AppendInt(aRecords[i].faviconID);
> >   }
> 
> no need for the extra space at the close parens either actually, i'll remove
> them before checkin. r=me otherwise.

[Sorry I'm nit-picking after check-in]
Presumably the space in ", " is just cosmetic as well.
Probably not worth writing home about unless the lists can run to thousands of ids...
Verified, there are no more query-in-loop patterns in these methods.
Status: RESOLVED → VERIFIED
Bug 451915 - move Firefox/Places bugs to Firefox/Bookmarks and History. Remove all bugspam from this move by filtering for the string "places-to-b-and-h".

In Thunderbird 3.0b, you do that as follows:
Tools | Message Filters
Make sure the correct account is selected. Click "New"
Conditions: Body   contains   places-to-b-and-h
Change the action to "Delete Message".
Select "Manually Run" from the dropdown at the top.
Click OK.

Select the filter in the list, make sure "Inbox" is selected at the bottom, and click "Run Now". This should delete all the bugspam. You can then delete the filter.

Gerv
Component: Places → Bookmarks & History
QA Contact: places → bookmarks
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: